DexoTronic Posted March 28, 2010 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?
robhol Posted March 28, 2010 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. Do NOT PM ME for help unless invited. - New MTA Script Editor Scripting help "etiquette": understandable language, relevant code (ALL code if unsure), [Lua] tags, error messages with line numbers. Super simple stuff.
DexoTronic Posted March 28, 2010 Author 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
50p Posted March 28, 2010 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 - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
DexoTronic Posted March 28, 2010 Author 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 ?
karlis Posted March 28, 2010 Posted March 28, 2010 use onVehicleEnter, removePedFromVehicle [WIP]GTA IV style hud+custom blips + blip text + circular radar areas
DexoTronic Posted March 28, 2010 Author 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
50p Posted March 28, 2010 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. - MTA Script Editor - Ask your scripting questions properly, please. - 50p's public resources - Meta.xml - what is it for? How is it possible LOL
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