NotAvailable Posted December 22, 2010 Share Posted December 22, 2010 Hi, im currently working on a Player Panel for my server. So that they can spawn cars and so on. But when i spawn a car, I cannot enter the car. Heres the code(client-side): function sultan() local client = getLocalPlayer() local x,y,z = getElementPosition ( client ) local r = getElementRotation ( client ) vehicle = createVehicle ( 560, x, y+5, z+1, 0, 0, r ) outputChatBox("Bulletproof sultan spawned!", 0, 255, 0, client) end There are no errors in the code but when i spawn the car, I cannot enter it. How to fix this? Regards, Jesseunit Link to comment
12p Posted December 22, 2010 Share Posted December 22, 2010 Important Note: Vehicles (and other elements) created client-side are only seen by the client that created them, aren't synced and players cannot enter them. They are essentially for display only. https://wiki.multitheftauto.com/wiki/CreateVehicle Link to comment
NotAvailable Posted December 22, 2010 Author Share Posted December 22, 2010 Important Note: Vehicles (and other elements) created client-side are only seen by the client that created them, aren't synced and players cannot enter them. They are essentially for display only. https://wiki.multitheftauto.com/wiki/CreateVehicle oh thanks ^^ Link to comment
NotAvailable Posted December 23, 2010 Author Share Posted December 23, 2010 No problems =) Oh, 1 more problem. Im making an VIP Panel for my server, But how do i trigger the server side event when the VIP clicks on the Spawn button? I tried addEvent, addEventHandler & triggerClientEvent, But it didnt worked. How do i fix that? Link to comment
Aibo Posted December 23, 2010 Share Posted December 23, 2010 use addEvent, addEventHandler on server side and triggerServerEvent in the client Link to comment
NotAvailable Posted December 23, 2010 Author Share Posted December 23, 2010 use addEvent, addEventHandler on server side and triggerServerEvent in the client ty Link to comment
NotAvailable Posted December 23, 2010 Author Share Posted December 23, 2010 Ok, its working but i still have 1 error: ERROR: npanel\panel_s.lua:40: attempt to call global 'getLocalPlayer' (a nil value) How do i fix that Link to comment
12p Posted December 23, 2010 Share Posted December 23, 2010 Dont doublepost... getLocalPlayer is a CLIENT value, NOT SERVER Link to comment
NotAvailable Posted December 23, 2010 Author Share Posted December 23, 2010 Dont doublepost... getLocalPlayer is a CLIENT value, NOT SERVER So what do i need to use then? Link to comment
12p Posted December 23, 2010 Share Posted December 23, 2010 I don't know. Investigate wiki functions maybe? I'll give you a clue: triggering =) Link to comment
NotAvailable Posted December 23, 2010 Author Share Posted December 23, 2010 I don't know. Investigate wiki functions maybe? I'll give you a clue: triggering =) Ill search for it. Ill reply soon Link to comment
jkMonger Posted December 23, 2010 Share Posted December 23, 2010 AddEvent and AddEventHandler, and TriggerServerEvent. Link to comment
12p Posted December 23, 2010 Share Posted December 23, 2010 Can't he investigate, man?!?! Can't he discover it by himself and learn more about it in Wiki?!?! Link to comment
NotAvailable Posted December 23, 2010 Author Share Posted December 23, 2010 still not working, i tried getPlayerFromName. this is the code(client) function sultan() triggerServerEvent("spawnSultan", getLocalPlayer()) end this the server side code: addEvent("spawnSultan", true) function warpIntoCar(playerName) local player = getPlayerFromName( playerName ); local x, y, z = getElementPosition ( player ) local r = getPedRotation ( player ) vehicle = createVehicle ( 560, x, y, z, 0, 0, r ) warpPedIntoVehicle ( player, vehicle ) end addEventHandler ( "spawnSultan", getRootElement(), warpIntoCar ) Link to comment
DakiLLa Posted December 23, 2010 Share Posted December 23, 2010 I don't see you are sending a client player's name in triggerServerEvent, so your 'warpIntoCar' function gets no any parameters. How to fix: function sultan() triggerServerEvent( "spawnSultan", getLocalPlayer(),getPlayerName( getLocalPlayer() ) ) end Link to comment
dzek (varez) Posted December 23, 2010 Share Posted December 23, 2010 why playername? just use "source" on server side event handler Link to comment
NotAvailable Posted December 23, 2010 Author Share Posted December 23, 2010 ty all it works Link to comment
Aibo Posted December 23, 2010 Share Posted December 23, 2010 you're not passing any arguments to server event, so playerName is nil. use source, it is the player element which triggered the event. 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