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

560x95_FFFFFF_B7FF00_000000_000000.png
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 
  

BETTER THEN YOU MOM

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.

560x95_FFFFFF_B7FF00_000000_000000.png
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.

Do not yield your back to your enemy, might feel something strange in your ass.

Two things are infinite the universe and human stupidity and i'm not sure about the universe.

UF: IsTextInGridList | GetGridListRowIndexFromText | Table.removeValue | removeHex | dxDrawTriangle

Skype: SaSuki102 | About Me | Youtube channel | Lua Tips & Tricks | Lua Strings | Lua Tables | Lua Operators

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 .

560x95_FFFFFF_B7FF00_000000_000000.png

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