Jump to content

SetTimer help


stefutz101

Recommended Posts

Posted

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 ! :)

Posted

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 
  

Posted

If i change :

  
givePedWeapon(player, 31, 5000, true) 

with :

setElementData(source,"GPS",1) 

Works ?

Because gamemode is dayz and if i use that function weapon dont appear in invetory.

Posted
Ok i will try , i will come with an answer . Thanks!

Don't follow him he already gave you a bad example.

you need to replace client with source .

the source of this event onPlayerSpawn is the player that just spawned.

Posted

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 .

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