Jump to content

My script doesn't work :( (SetAccountdata)


Andres99907

Recommended Posts

function comprarbandito ( thePlayer, command)
     local playeraccount = getPlayerAccount ( source )
     takePlayerMoney ( thePlayer, 500000 )
     setAccountData ( playeraccount, "rc.bandito", adquirido )
end
addCommandHandler ( "comprarbandito", comprarbandito )

function Banditoadquirido (_, playeraccount )
      if ( playeraccount ) then
            local ban = getAccountData ( playeraccount, "rc.bandito" )
            if ( ban ) then
                  Banditocomprado = true
            end
      end
end
addEvent ( "banditobuyed", true )
addEventHandler ( "banditobuyed", getRootElement(), Banditoadquirido )

This function takes 500000 dollars to give a player permission to use a RC Bandito in a gui (Like in GTA Online)

but, when i put the command "comprarbandito"  Bad argument @ getplayeraccount, got nil, i never used getplayeraccount or setplayeraccount, and i don't know if the other function (Banditoadquirido) will work :( 

Link to comment
  • Moderators
1 hour ago, Andres99907 said:

argument @ getplayeraccount, got nil

source is only available for events (functions that are executed when an event is triggered +addEventHandler). So it's value is in this case nil(no  value).

Use thePlayer instead, since you need a player element for the function 'getPlayerAccount.'

  • Like 1
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...