Castillo Posted June 10, 2010 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
dzek (varez) Posted June 10, 2010 Posted June 10, 2010 source == repair what is repair? Multi theft auto tools - replace cars and peds, move your map or compile your Lua files online! programista php rzeszów Need free webhosting for your small site? PM me. Need help with portforwarding? PM me. Do not PM me asking for help with scripting. Having problems with port forwarding? Send me pm, I can do whole thing for you using TeamViewer (already helped about 20 people, no worries)!
Castillo Posted June 10, 2010 Author Posted June 10, 2010 source == repairwhat is repair? a button. San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted June 11, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Castillo Posted June 11, 2010 Author 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" San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted June 11, 2010 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 - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Castillo Posted June 11, 2010 Author Posted June 11, 2010 if i rename all "client" to "player" all functions stops working San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
50p Posted June 11, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
Castillo Posted June 11, 2010 Author 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 San Andreas Utopia RPG (SAUR) Owner & Developer. Education is the most powerful weapon which you can use to change the world.
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