Jump to content

Cant Save Account :(


DexoTronic

Recommended Posts

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

- 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
- 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

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

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

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...