Jump to content

addEventHandler problem with argument


John Smith

Recommended Posts

Uh, that makes no sense.

Problems:

1º removeEventHandler arguments are: attachedTo, function. And if you remove it, nobody else will be able to spawn when join.

2º bindKey server-side requires a player element, "player" is not defined there. Bind it when the player joins.

Link to comment
Uh, that makes no sense.

Problems:

1º removeEventHandler arguments are: attachedTo, function. And if you remove it, nobody else will be able to spawn when join.

2º bindKey server-side requires a player element, "player" is not defined there. Bind it when the player joins.

I've removed that removeEventHandler but i didn't understand clearly what u meant with 2)

is this good?

function onSumoPlayerVehicleExit(player) 
    if isPedInVehicle(player) then 
    killPed(player) 
else 
    outputDebugString("a player pressed enter/f key without being in a vehicle.") 
end 
end 
  
addEventHandler("onVehicleStartExit",root,onSumoPlayerVehicleExit) 
  
function bindKill(player) 
bindKey(player, "enter", "down", onSumoPlayerVehicleExit) 
bindKey(player, "f", "down", onSumoPlayerVehicleExit) 
end 
addEventHandler("onPlayerJoin",root,bindKill) 

btw idk how to set a timer when player should respawn(5 sec) xD

Link to comment

Why ask if it's good or not ? First you should try it, instead of waiting for someone to say if it's good or bad.

btw idk how to set a timer when player should respawn(5 sec) xD

addEventHandler ( "onPlayerWasted", getRootElement(), 
function () 
setTimer(function() 
-- RESPAWN CODE HERE 
end, 5000, 1 ) 
end) 

Edited by Guest
Link to comment
function respawnSumoPlayer() 
addEventHandler("onPlayerWasted",getRootElement(), 
setTimer(function() 
spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) 
setCameraTarget ( source, source ) 
end, 5000, 1 )) 
end 

im not respawning and my camera is going higher and higher because im dead

[10:19:12] WARNING: [gamemodes]\[sumo]\sumo\load_map\spawn_s.lua:34: Bad argument @ 'spawnPlayer'

[10:19:12] WARNING: [gamemodes]\[sumo]\sumo\load_map\spawn_s.lua:35: Bad argument @ 'setCameraTarget

Link to comment

i've tried this too

addEventHandler("onPlayerWasted", root, 
    function()  
    setTimer( 
        function(source)  
        local vehicle = createVehicle ( model, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) 
        spawnPlayer ( source, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) )  ) 
        setCameraTarget ( source, source )       
        warpPedIntoVehicle ( source, vehicle ) 
        end, 5000, 1, source )   
    end)  

it respawns me but how can i make it respawn me into random vehicle?

Link to comment
addEventHandler ( "onPlayerWasted", root, 
    function ( ) 
        setTimer ( 
            function ( thePlayer ) 
                if isElement ( thePlayer ) then 
                    local model = vehicles [ math.random ( #vehicles ) ] 
                    local vehicle = createVehicle ( model, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) 
                    spawnPlayer ( thePlayer, unpack ( spawnPoints [ math.random ( #spawnPoints ) ] ) ) 
                    setCameraTarget ( thePlayer, thePlayer )      
                    warpPedIntoVehicle ( thePlayer, vehicle ) 
                end 
            end 
            ,5000, 1, source 
        ) 
    end 
) 

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