Jump to content

Timer


WelCome

Recommended Posts

Posted
function timer(player)
    if getPlayerTeam(player)==team then
    print("Work")
local losuj math.random(1,3)
if losuj==1 then
givePlayerMoney(player,2000)
elseif losuj==2 then
setPedArmor(player,100)
setElementHealth(player,100)
elseif losuj==3 then
giveWeapon(player,36,3)
end
end
end
setTimer(timer,2000,0,source)

DebugScript 3 : Bad argument 'getPlayerTeam' [Expected player at argument 1,got nil] 

Posted (edited)

Because you are passing an invalid player element with

setTimer(timer,2000,0,source)

where is 'source' player element defined?

And that's not the only thing wrong in your code.

Edited by Mega9
Posted (edited)
15 minutes ago, Mega9 said:

Because you are passing an invalid player element with


setTimer(timer,2000,0,source)

where is 'source' player element defined?

And that's not the only thing wrong in your code.

I changed it, but it does not work

sry for bad english i use google translator

Edited by WelCome
Posted

dude get player team means valid team not a 'team' correct code will be like these

if ( getTeamName(getPlayerTeam(thePlayer)) == "Staff" ) then

it will work now take a look!

Posted

can u try this ?

function timer(player)
   -- if getPlayerTeam(player)==team then
		print("Work")
		local losuj = math.random(1,3)
		if losuj==1 then
			givePlayerMoney(player,2000)
		elseif losuj==2 then
			setPedArmor(player,100)
			setElementHealth(player,100)
		elseif losuj==3 then
			giveWeapon(player,36,3)
		end
	--end
end

function allPlayers()
	for i,player in pairs(getElementsByType("player")) do
		if getPlayerTeam(player)==team then -- check
			timer(player)
		end
	end
	setTimer(allPlayers,2000,1)
end
allPlayers()

 

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