Jump to content

Remove of a argument.


Recommended Posts

I will try that, but it is a variable i want to change, like

A = getPlayerName

and then -remove something from A- were A is a variable ofcourse.

EDIT: It gives a unexpected symbol near return, my code:

B = getElementPosition ( player ) 
A = return string.gsub ( "B", "GNR", "" ) 

This is just an example because there is no GNR in a position ;)

Link to comment

If I understood you correct:

addEventHandler ( 'onPlayerChat', root,  
    function ( message, messageType ) 
        if ( messageType ) == 0 then 
            if ( message ) == 'GNR45' then 
                cancelEvent ( ) 
                outputChatBox ( message:gsub ( 'GNR', '' ) ) 
                outputServerLog( "CHAT: " .. getPlayerName ( source ).. ": " .. message ) 
            end 
        end 
    end 
) 
  

I didn't tested yet.

Link to comment

Almost, it isnt chat tough, let me explain better :) I have a gridlist in a GUI were you can select thing's it retrieves what you selected fine and call that V ( v = etc. ) Then i need to remove "row" from V, im sure it contains row, and it needs to call the V without "row" ID, that id is then passed to serverside. I got some stuff from what you just gave me: id = v:gsub ( 'row', '' )

This gives me Attempt to index global v ( a number value ) on the the line v:gsub.

Link to comment

( im a noob at LUA ) can you explain me what this does? And how it works?

EDIT: Looked something up, it converts it right? What if i use tostring, remove "row" and then use tonumber?

EDIT2: That doesnt work :( It should become a id of a vehicle.

Link to comment
function create_veh ( playerSource ) 
v = guiGridListGetSelectedItem ( list_vehicles ) 
id1 = tostring(v) 
id2 = id1:gsub ( 'row', '') 
id = tonumber(id2) 
x, y, z = getElementPosition ( getLocalPlayer () ) 
showCursor ( false ) 
guiSetVisible ( Main_Window, false ) 
outputChatBox(". " .. id1 .. " ! and " .. id2 .. "  !" ) 
createVehicle ( id, x + 2, y + 1, z + 1.5 ) 
triggerServerEvent ( spawn, getLocalPlayer (), id ) 
end 

I have found a alternative solution, but i would like to learn it.

Link to comment

Oh now I finally know what you want. The problem is that guiGridListGetSelectedItem will not return the text, but the index of the selected row and column in the gridlist. You then have to use that with guiGridListGetItemText, which will grab the text from your gridlist :)

This should do what you want:

function create_veh ( playerSource ) 
    local row,column = guiGridListGetSelectedItem ( list_vehicles ) 
    id = guiGridListGetItemText(row,column) 
    x, y, z = getElementPosition ( getLocalPlayer () ) 
    showCursor ( false ) 
    guiSetVisible ( Main_Window, false ) 
    createVehicle ( id, x + 2, y + 1, z + 1.5 ) 
    triggerServerEvent ( spawn, getLocalPlayer (), id ) 
end 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...