DexoTronic Posted March 28, 2010 Share Posted March 28, 2010 Hello, its me again^^ My Problem is: function truckerannehmen_func ( ) setPedSkin ( source, 34 ) PlayerJob[source] = tonumber(2) end addEvent ( "truckerannehmen", true ) addEventHandler ( "truckerannehmen", getRootElement(), truckerannehmen_func ) After the Player accepts a Job, his skin will change and PlayerJob[source] will be set to "2". But it doesnt work. I have this code on playerquit: setAccountData ( account[source], "Job", PlayerJob[source] ) PlayerJob[source] = nil But after the player quits, in the account data is still written "1" for job it should be "2" now. I dont get any errors, but what is wrong? Link to comment
robhol Posted March 28, 2010 Share Posted March 28, 2010 - Where do you trigger the event? - Why use account[source] (is it defined and set to the appropriate value?) when you can use getPlayerAccount? - Don't code in German because it makes reading it a pain in the ass for people who might help you. Link to comment
DexoTronic Posted March 28, 2010 Author Share Posted March 28, 2010 - Where do you trigger the event?- Why use account[source] (is it defined and set to the appropriate value?) when you can use getPlayerAccount? - Don't code in German because it makes reading it a pain in the ass for people who might help you. 1. function onClickBtn ( button, state ) if (button == "left" and state == "up") then if (source == TruckAnnehmenBtn ) then guiSetInputEnabled(false) guiSetVisible ( TruckWindow , false ) showCursor ( false ) triggerServerEvent ( "truckerannehmen", getRootElement()) end if (source == TruckAblehnen ) then guiSetInputEnabled(false) guiSetVisible ( TruckWindow , false ) showCursor ( false ) end end end account[source] = getPlayerAccount ( source ) the trigger works, it changes the skin on btn click but it doesnt save after i quit Link to comment
50p Posted March 28, 2010 Share Posted March 28, 2010 Because source in that function is root element not player. client: the client that triggered the event using triggerServerEvent. Not set if the event was not triggered from a client. Use client instead. And there is no need to convert number to number. PlayerJob[client] = 2 Link to comment
DexoTronic Posted March 28, 2010 Author Share Posted March 28, 2010 worked... i love you man another question, i dont want to spam the board with new threads ^^ : i create a vehicle with truck1 = createvehicle(...) is there a way to detect if player enters the "truck1" ? and throw him out of the vehicle if PlayerJob[client] isnt = 2 ? Link to comment
karlis Posted March 28, 2010 Share Posted March 28, 2010 use onVehicleEnter, removePedFromVehicle Link to comment
DexoTronic Posted March 28, 2010 Author Share Posted March 28, 2010 yes but that works with vehicleIDs only.. i want to make it work with the variable i have given to the vehicle Link to comment
50p Posted March 28, 2010 Share Posted March 28, 2010 yes but that works with vehicleIDs only.. i want to make it work with the variable i have given to the vehicle source of onVehicleEnter is vehicle element of the vehicle that was entered. 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