WelCome

Timer

Recommended Posts

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] 

Share this post


Link to post

May you please put this in a properly formatted lua bracket? After you do that I'll be glad to help you.

Share this post


Link to post

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

Share this post


Link to post
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

Share this post


Link to post

Can you please explain what you are trying to achieve?

Share this post


Link to post

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!

Share this post


Link to post

@Khadeer143 it won't work. This script isn't passing a valid player element.

Share this post


Link to post

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()

 

Share this post


Link to post

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.