Castillo Posted June 10, 2010 Share Posted June 10, 2010 hey, while scripting my panel i got stuck in a function that seems to dont work, i will post code here maybe someone can help me. server: function fixVehicle(client) local theVehicle = getPedOccupiedVehicle ( client ) if ( theVehicle ) then fixVehicle ( theVehicle ) local rx, ry, rz = getVehicleRotation ( theVehicle ) if ( rx > 110 ) and ( rx < 250 ) then local x, y, z = getElementPosition ( theVehicle ) setVehicleRotation ( theVehicle, rx + 180, ry, rz ) setElementPosition ( theVehicle, x, y, z + 2 ) end end end client: function repairVehicle() if source == repair then selectedPlayer = guiGridListGetItemText ( playersList, guiGridListGetSelectedItem (playersList), 1 ) if ( guiGridListGetSelectedItem ( playersList ) ~= -1 ) then triggerServerEvent ("repairVeh", getRootElement(), selectedPlayer, client) else outputChatBox("No user selected.", nil , 255, 0, 0, false) end end end Link to comment
dzek (varez) Posted June 10, 2010 Share Posted June 10, 2010 source == repair what is repair? Link to comment
Castillo Posted June 10, 2010 Author Share Posted June 10, 2010 source == repairwhat is repair? a button. Link to comment
50p Posted June 11, 2010 Share Posted June 11, 2010 When you create a function with the name of one native MTA function, you overwrite it.. That will make MTA fixVehicle function unavailable... Be careful when naming your functions. Link to comment
Castillo Posted June 11, 2010 Author Share Posted June 11, 2010 When you create a function with the name of one native MTA function, you overwrite it.. That will make MTA fixVehicle function unavailable... Be careful when naming your functions. ok, i changed to repairVehicle as function name but still same problem with getPedOccupiedVehicle, this is the error. Bad argument @ "getPedOccupiedVehicle" Link to comment
50p Posted June 11, 2010 Share Posted June 11, 2010 When you create a function with the name of one native MTA function, you overwrite it.. That will make MTA fixVehicle function unavailable... Be careful when naming your functions. ok, i changed to repairVehicle as function name but still same problem with getPedOccupiedVehicle, this is the error. Bad argument @ "getPedOccupiedVehicle" Your client parameter will be string (player's name from grid list, I suppose), this will also overwrite MTA's client variable which is passed to server event with triggerServerEvent. Just rename the parameter name to something more like what the argument will be (like playerName) and inside the function getPlayerFromName. Also, change all the client to player and try this code: function repairVehicle( playerName ) local player = getPlayerFromName( playerName ); -- rest of your code ... end Link to comment
Castillo Posted June 11, 2010 Author Share Posted June 11, 2010 if i rename all "client" to "player" all functions stops working Link to comment
50p Posted June 11, 2010 Share Posted June 11, 2010 if i rename all "client" to "player" all functions stops working Use my code... As you can see, there is new player variable and client is changed to playerName. Link to comment
Castillo Posted June 11, 2010 Author Share Posted June 11, 2010 if i rename all "client" to "player" all functions stops working Use my code... As you can see, there is new player variable and client is changed to playerName. thanks now finally works :D Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now