1. Check out the Store if you're looking to Buy HL2RP or other schemas for your server. You can click Buy Schemas on the very top navigation bar to visit the store.
  2. Use the Plugin Center to easily subscribe to and auto-install Clockwork plugins to your server, or submit and share plugins you have developed.
  3. Having trouble setting up or developing with Clockwork? Check out the Wiki or post in the Support Forum for advice from fellow users.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

Removing a part of a string

Discussion in 'Help' started by MKW9813, Nov 11, 2012.

Thread Status:
Not open for further replies.
  1. MKW9813

    MKW9813 The community REDCAT-Gaming has to put up with me.

    Hello! I am attempting to script a GUI for the datapad that is used in HL2RP. I have it running off commands that are entered into the GUI. The one thing I cannot understand is how to remove a part of a string from another.

    Example: I type 'EDITDATA 25364', and I only want the 25364 left of it. Got any ideas?
     
  2. alexgrist

    alexgrist Guest

    string.Explode and use " " as the separator then use the second value in the table.
     
  3. MKW9813

    MKW9813 The community REDCAT-Gaming has to put up with me.

    Thanks for the reply, but the if statement I have setup to read the command won't pick it up. This is the code for the command box (For some reason it won't let me insert this in the 'code' bracket:


    local cmdBox = vgui.Create("DTextEntry")

    cmdBox:SetParent(datapad)
    cmdBox:SetPos(20, 50)
    cmdBox:SetTall(20)
    cmdBox:SetWide(260)
    cmdBox:SetEnterAllowed(true)
    cmdBox.OnEnter = function()
    local stringExp = string.Explode(" ", cmdBox:GetValue())
    -- Exit Command
    PrintTable(stringExp)
    if (cmdBox:GetValue() == "LOGOFF") then
    datapad:SetVisible(false)
    elseif (cmdBox:GetValue() == "TETRIS") then
    openTetrisBox()
    elseif (stringExp[1] == "EDITDATA") then
    ply:ChatPrint(stringExp[2])
    else
    ply:ChatPrint("<:: COMMAND NOT FOUND")
    end
    end
     
  4. Razor

    Razor Guest

    Try GetText instead of GetValue?
     
  5. MKW9813

    MKW9813 The community REDCAT-Gaming has to put up with me.

    Nope, it still prints to the chat 'Command not found'. The other commands work, just not the one that uses the string.Explode().
     
  6. RTLK

    RTLK Active Member

    do this:

    elseif (stringExp[1] == "EDITDATA") then
    ply:ChatPrint(stringExp[2])
    else
    ply:ChatPrint("<:: COMMAND NOT FOUND")
    ply:ChatPrint(stringExp[1])
    end

    Then you can see what it is saying stringExp[1] is
     
  7. MKW9813

    MKW9813 The community REDCAT-Gaming has to put up with me.

    I got it now, I made a tiny typo in the code.

    Thanks for the help.
     

Previous Readers (Total: 0)

Thread Status:
Not open for further replies.