Jump to content

[Solved] Spawn Script


Recommended Posts

Posted (edited)

So, first... I'm really noob at programming, and I was trying to create a spawn screen script...

But when the even is called, it calls all the commands but the spawnPlayer... It says it is expecting a player at argument 1, but i really don't know what to put in there. I've looked a lot of MTA Wiki pages, tried a lot of things but i can't make it work.

It could be a really stupid thing, but as I said, im really new at programming.

1Q2l4vi.png

Thanks to CodyL, for the fix :D

Edited by Guest
Posted

Can you show us how you called onSpawnPoliceOfficerLS?

Also, if you want you can just post your code in [lua] and [ / lua] tags instead of uploading photos to another website and showing, might save you some time. :P

Posted

change player source to client assuming this is a server side script and being called from a client side.

If not, post the section of code that calls this function. You may need to put (PlayerSource) in the brackets for this function if it is being sent over by the calling function.

Posted

This is the client side script:

rootElement = getRootElement() 
  
-- Lots of things in between...  
  
function spawnPoliceOfficerLS ( button ) 
    if button == "left" then 
        triggerServerEvent("onSpawnPoliceOfficerLS", rootElement) 
    end 
end 

It calls the server side when player click the button to spawn.

Posted

in the PoliceOfficerLS function

replace

source 
playerSource 

with

client 

You are calling a server side event from a client side even, when triggering a server side event it does not pass the player as source, instead of passes the player as 'client'.

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