Jump to content

This script doesn't work (PayDay for Team) [SOLVED]


KiffShark

Recommended Posts

Hi again!

I have done a script of "PayDay" for a team, but it doesn't work

Someone can help me?

(The team isn't the problem, it is created correctly in the same resource and works in the game)

It's strange but I used this strcture because I saw it in a resource :/

addEventHandler("onResourceStart", function genPayDay(player) if getPlayerTeam(player, "gen") then 
    outputChatBox ( "*------------ payday ------------", value, 0, 255, 0)  
    outputChatBox ( "*text1", value, 0, 255, 0)  
    outputChatBox ( "*text2", value, 0, 255, 0)  
    outputChatBox ( "*text3", value, 0, 255, 0) 
    for i, v in ipairs(getElementsByType("player")) do  
    givePlayerMoney ( value, 500 ) 
    setTimer ( genPayDay, 10000, 0 ) 
  end 
else 
end 
end 
) 

(the timer is 10s only for test it, when it works i will put 24 minutes)

I've test 100000 ways of code that looks better than this thing xD before -.- anyone has worked..

If someone can fix it or give another suggestion I'd be so pleased :(

console:

[2012-10-26 16:02:14] WARNING: psg\job.server.lua:57: Bad argument @ 'addEventHandler' [Expected element at argument 2, got function]

Problem here:

addEventHandler("onResourceStart", function genPayDay(player) if getPlayerTeam(player, "gen") then

(But I have seen this in a resource that works correctly._.)

Thanks!

(sorry for my english and if the script looks made by a baby xD)

Edited by Guest
Link to comment

ok i guess it xDD that's why i 've said sorry if looks made by a baby xD

(I want that players in team Gen will receive $500 every 24 mins) (in the last code was 10 secs but only for test it)

I tried this too

function genPayDay() 
    local team = getPlayerTeam(source)  
    if team then  
    if getTeamName(team) == gen then  
    givePlayerMoney ( value, 500 )  
    outputChatBox ( "*--------------- payday ---------------", value, 0, 255, 0)  
    outputChatBox ( "*text1", value, 0, 255, 0)  
    outputChatBox ( "*text2.", value, 0, 255, 0)  
    outputChatBox ( "*text3", value, 0, 255, 0)  
  end 
end 
  
function onResourceStart(thisResource) 
  setTimer ( genPayDay, 720000, 0 ) 
end 
addEventHandler ( "onResourceStart", getResourceRootElement(getThisResource()), onResourceStart ) 

but doesn't work

what do you think?

Edited by Guest
Link to comment

try this :

(edited)

  
  
    addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
    function () 
      local  aTimer=setTimer ( genPayDay, 10000, 0 ) 
    end 
    ) 
     
    function genPayDay() 
    for i, player in ipairs(getElementsByType("player")) do  
     local theTeam=getPlayerTeam(player) 
if theTeam then 
    if getTeamName(theTeam)=="gen" then 
        outputChatBox ( "*------------ payday ------------", player, 0, 255, 0) 
        outputChatBox ( "*text1", player, 0, 255, 0) 
        outputChatBox ( "*text2", player, 0, 255, 0) 
        outputChatBox ( "*text3", player, 0, 255, 0) 
        givePlayerMoney ( player, 500 ) 
 end  
 end 
    end  
    end 
  

Link to comment

console:

[2012-10-26 17:02:39] WARNING: psg\job.server.lua:65: Bad argument @ 'getTeamName'

and I don't receive money when i'm in gen team

in other file of the same resource is created the team (works)

gen = createTeam ( "Gen", 255, 0, 0 ) 
setTeamFriendlyFire(gen, false) 

Link to comment

well i think it should work now

cuz u said the team name is "Gen" not "gen"

  
    addEventHandler("onResourceStart", getResourceRootElement(getThisResource()), 
    function () 
      local  aTimer=setTimer ( genPayDay, 10000, 0 ) 
    end 
    ) 
     
    function genPayDay() 
    for i, player in ipairs(getElementsByType("player")) do  
     local theTeam=getPlayerTeam(player) 
if theTeam then 
    if getTeamName(theTeam)=="Gen"  then 
        outputChatBox ( "*------------ payday ------------", player, 0, 255, 0) 
        outputChatBox ( "*text1", player, 0, 255, 0) 
        outputChatBox ( "*text2", player, 0, 255, 0) 
        outputChatBox ( "*text3", player, 0, 255, 0) 
        givePlayerMoney ( player, 500 ) 
 end  
 end 
    end  
    end 
  

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