Jump to content

[HELP]Cannot enter spawned car


NotAvailable

Recommended Posts

Posted

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

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

Posted

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 ) 

Posted

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 

Posted

you're not passing any arguments to server event, so playerName is nil.

use source, it is the player element which triggered the event.

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