Jump to content

SetTimer help


stefutz101

Recommended Posts

Hi i want to make a system what give you guns at spawn on a dayz server .

First time i try with :

addEventHandler("onPlayerSpawn",root, 
function () 
    setElementData(source,"GPS",1) 
    outputChatBox("ok",source,255,0,0) 
end) 
  

After that i realized : at spawn spawn.lua set you items on 0. So i think I need a delay to give that guns , so i try

addEventHandler("onPlayerSpawn",root, 
function () 
    setTimer ( function() 
        setElementData(source,"GPS",1) 
    end, 5000, 1 ) 
    outputChatBox("ok",source,255,0,0) 
end) 
  

No errors or warnings , thanks in advance ! :)

Link to comment

Hm... you Use TriggerClientEvent.

    addEventHandler("onPlayerSpawn",root, 
    function () 
        setTimer ( function() 
            setElementData(source,"GPS",1) 
        end, 5000, 1 ) 
        outputChatBox("ok",source,255,0,0) 
triggerClientEvent( client, "Triggers", client) 
    end) 
     
  
--#Client 
addEvent("Triggers", true) 
addEventHandler("Triggers", root, 
function(player) 
givePedWeapon(player, 31, 5000, true)  
end 
  

Link to comment

It works , but it works only first time . After the secound spawn i don't have any items . But if I restart resource and type /kill it work , but only at first kill .

triggerClientEvent( client, "Triggers", client) 

Yes , i change "client" with "source" and it works , but only first time .

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