SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 15/12/2010, 04:58 PM   #1
matute
Big Clucker
 
matute's Avatar
 
Join Date: Apr 2008
Location: Argentina
Posts: 108
Reputation: 0
Question Help with Timer

Hi guys im needing help with some timers i did for my server.
Lets go with the first:

Code:
forward PayDay(playerid);
public OnGameModeInit()
{
SetTimer("PayDay", 1440000, 1);
}
public PayDay(playerid)
{
    new level = PlayerInfo[playerid][pLevel];
    
    if(gClass[playerid] == 0)
	{
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE, "       PAYDAY       ");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE,  "You got payed for your daily service");
        SendClientMessage(playerid, COLOR_WHITE,  "You got $2000 and 1 level up");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
		GivePlayerMoney(playerid, 2000);
		SetPlayerScore(playerid, level+1);
		return 1;
	}
	if(gClass[playerid] == 2)
 	{
      	SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE, "       PAYDAY       ");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE,  "You got payed for your daily service");
        SendClientMessage(playerid, COLOR_WHITE,  "You got $20000 and 1 level up");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
		GivePlayerMoney(playerid, 20000);
		SetPlayerScore(playerid, level+1);
		return 1;
	}
	if(gClass[playerid] == 1 || gClass[playerid] == 3 || gClass[playerid] == 4 || gClass[playerid] == 5 || gClass[playerid] == 6 || gClass[playerid] == 7)
 	{
 	SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE, "       PAYDAY       ");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE,  "You Are not jobing.");
        SendClientMessage(playerid, COLOR_WHITE,  "In order to get a payday, get a job first.");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
		return 1;
	}
	if(gClass[playerid] == 8 || gClass[playerid] == 9 || gClass[playerid] == 10 || gClass[playerid] == 11 || gClass[playerid] == 12 || gClass[playerid] == 13 || gClass[playerid] == 14 || gClass[playerid] == 15 || gClass[playerid] == 16 || gClass[playerid] == 17 || gClass[playerid] == 18 || gClass[playerid] == 19 || gClass[playerid] == 20 || gClass[playerid] == 21 || gClass[playerid] == 22 || gClass[playerid] == 23)
 	{
 	SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE, "       PAYDAY       ");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE,  "You Are not jobing.");
        SendClientMessage(playerid, COLOR_WHITE,  "In order to get a payday, get a job first.");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
		return 1;
	}
	if(gClass[playerid] == 25)
	{
	SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE, "       PAYDAY       ");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE,  "You got payed for your daily service");
        SendClientMessage(playerid, COLOR_WHITE,  "You got $5000 and 1 level up");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
		GivePlayerMoney(playerid, 5000);
		SetPlayerScore(playerid, level+1);
		return 1;
	}
	if(gClass[playerid] == 26)
 	{
 	    SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE, "       PAYDAY       ");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE,  "You got payed for your daily service");
        SendClientMessage(playerid, COLOR_WHITE,  "You got $20000 and 1 level up");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
		GivePlayerMoney(playerid, 20000);
		SetPlayerScore(playerid, level+1);
		return 1;
	}
	if(gClass[playerid] == 27)
 	{
 	SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE, "       PAYDAY       ");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE,  "You got payed because you are VIP");
        SendClientMessage(playerid, COLOR_WHITE,  "You got $10000 and 1 level up");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
		GivePlayerMoney(playerid, 10000);
		SetPlayerScore(playerid, level+1);
		return 1;
	}
	if(gClass[playerid] == 24)
 	{
 	SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE, "       PAYDAY       ");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
        SendClientMessage(playerid, COLOR_WHITE,  "You got payed for your daily service");
        SendClientMessage(playerid, COLOR_WHITE,  "You got $2000 and 1 level up");
        SendClientMessage(playerid, COLOR_YELLOW, "====================");
		GivePlayerMoney(playerid, 2000);
		SetPlayerScore(playerid, level+1);
		return 1;
	}
	return 1;
}
Now the problem is that it gives the money to only one player, and not to the rest,it have to give a payday to everyone, can you help me with it please?
Thanks you so much and i wait for answers
matute is offline  
Old 15/12/2010, 05:03 PM   #2
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,714
Reputation: 3068
Default Re: Help with Timer

Where does playerid come from?
Y_Less is offline  
Old 15/12/2010, 05:05 PM   #3
matute
Big Clucker
 
matute's Avatar
 
Join Date: Apr 2008
Location: Argentina
Posts: 108
Reputation: 0
Default Re: Help with Timer

Quote:
Originally Posted by Y_Less View Post
Where does playerid come from?
Whats bad with playerid? I put playerid at the public fuction because GivePlayermoney needs it, right?
matute is offline  
Old 15/12/2010, 05:07 PM   #4
WillyP
High-roller
 
WillyP's Avatar
 
Join Date: Jul 2010
Location: England
Posts: 2,216
Reputation: 63
Default Re: Help with Timer

Quote:
Originally Posted by matute View Post
Whats bad with playerid? I put playerid at the public fuction because GivePlayermoney needs it, right?
All of that would only be for ID 0.
__________________
once average now terrible
WillyP is offline  
Old 15/12/2010, 05:08 PM   #5
matute
Big Clucker
 
matute's Avatar
 
Join Date: Apr 2008
Location: Argentina
Posts: 108
Reputation: 0
Default Re: Help with Timer

Quote:
Originally Posted by [FU]Victious View Post
All of that would only be for ID 0.
So what i have to change from it to pay everyone?
matute is offline  
Old 15/12/2010, 05:32 PM   #6
[MWR]Blood
High-roller
 
Join Date: Apr 2009
Posts: 2,365
Reputation: 105
Default Re: Help with Timer

Replace:
Code:
GivePlayerMoney(playerid, 20000);
SetPlayerScore(playerid, level+1);

with:
Code:
for(new i = 0;i < MAX_PLAYERS; i++)
{
GivePlayerMoney(i, 20000);
SetPlayerScore(i, level+1);
}
__________________
[MWR]Blood is offline  
Old 15/12/2010, 05:35 PM   #7
Y_Less
Spam Machine
 
Y_Less's Avatar
 
Join Date: Jun 2008
Location: 629 - git.io/Y
Posts: 14,714
Reputation: 3068
Default Re: Help with Timer

There is nothing wrong with playerid, I just want to know where you think it COMES from. Functions with parameters need that parameter to be passed from somewhere. What is passing the playerid parameter to your function? Just to clarify - the name doesn't mean squat, just because you call a variable "playerid" doesn't make it a player's ID - you could rename the variable "pink_elephant", that doesn't mean you will suddenly get coloured animals running around your server.

Edit: Or just have someone else give you the code without making you think or work in the slightest...
Y_Less is offline  
Old 15/12/2010, 05:44 PM   #8
matute
Big Clucker
 
matute's Avatar
 
Join Date: Apr 2008
Location: Argentina
Posts: 108
Reputation: 0
Thumbs up Re: Help with Timer

Quote:
Originally Posted by Y_Less View Post
There is nothing wrong with playerid, I just want to know where you think it COMES from. Functions with parameters need that parameter to be passed from somewhere. What is passing the playerid parameter to your function? Just to clarify - the name doesn't mean squat, just because you call a variable "playerid" doesn't make it a player's ID - you could rename the variable "pink_elephant", that doesn't mean you will suddenly get coloured animals running around your server.

Edit: Or just have someone else give you the code without making you think or work in the slightest...
I fixed it, thanks you Y_Less i made it by myself thats why it was bugged
Now i used
Code:
public PayDay()
{
   		for(new i = 0;i < MAX_PLAYERS; i++)
		{
			new level = PlayerInfo[i][pLevel];
			if(gClass[i] == 0)
			{
        	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE, "       PAYDAY       ");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE,  "You got payed for your daily service");
        	SendClientMessage(i, COLOR_WHITE,  "You got $2000 and 1 level up");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
			GivePlayerMoney(i, 2000);
			SetPlayerScore(i, level+1);
			return 1;
			}
			if(gClass[i] == 2)
			{
  			SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE, "       PAYDAY       ");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE,  "You got payed for your daily service");
        	SendClientMessage(i, COLOR_WHITE,  "You got $20000 and 1 level up");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
			GivePlayerMoney(i, 20000);
			SetPlayerScore(i, level+1);
			return 1;
			}
			if(gClass[i] == 1 || gClass[i] == 3 || gClass[i] == 4 || gClass[i] == 5 || gClass[i] == 6 || gClass[i] == 7)
			{
 	    	SendClientMessage(i, COLOR_YELLOW, "====================");
       	 	SendClientMessage(i, COLOR_WHITE, "       PAYDAY       ");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE,  "You Are not jobing.");
        	SendClientMessage(i, COLOR_WHITE,  "In order to get a payday, get a job first.");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
			return 1;
			}
			if(gClass[i] == 8 || gClass[i] == 9 || gClass[i] == 10 || gClass[i] == 11 || gClass[i] == 12 || gClass[i] == 13 || gClass[i] == 14 || gClass[i] == 15 || gClass[i] == 16 || gClass[i] == 17 || gClass[i] == 18 || gClass[i] == 19 || gClass[i] == 20 || gClass[i] == 21 || gClass[i] == 22 || gClass[i] == 23)
 			{
 	    	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE, "       PAYDAY       ");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE,  "You Are not jobing.");
        	SendClientMessage(i, COLOR_WHITE,  "In order to get a payday, get a job first.");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
			return 1;
			}
			if(gClass[i] == 25)
			{
	    	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE, "       PAYDAY       ");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE,  "You got payed for your daily service");
        	SendClientMessage(i, COLOR_WHITE,  "You got $5000 and 1 level up");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
			GivePlayerMoney(i, 5000);
			SetPlayerScore(i, level+1);
			return 1;
			}
			if(gClass[i] == 26)
 			{
 			SendClientMessage(i, COLOR_YELLOW, "====================");
      		SendClientMessage(i, COLOR_WHITE, "       PAYDAY       ");
      		SendClientMessage(i, COLOR_YELLOW, "====================");
      		SendClientMessage(i, COLOR_WHITE,  "You got payed for your daily service");
      		SendClientMessage(i, COLOR_WHITE,  "You got $20000 and 1 level up");
      		SendClientMessage(i, COLOR_YELLOW, "====================");
			GivePlayerMoney(i, 20000);
			SetPlayerScore(i, level+1);
			return 1;
			}
			if(gClass[i] == 27)
 			{
 	    	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE, "       PAYDAY       ");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE,  "You got payed because you are VIP");
        	SendClientMessage(i, COLOR_WHITE,  "You got $10000 and 1 level up");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
			GivePlayerMoney(i, 10000);
			SetPlayerScore(i, level+1);
			return 1;
			}
			if(gClass[i] == 24)
 			{
 	    	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE, "       PAYDAY       ");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
        	SendClientMessage(i, COLOR_WHITE,  "You got payed for your daily service");
        	SendClientMessage(i, COLOR_WHITE,  "You got $2000 and 1 level up");
        	SendClientMessage(i, COLOR_YELLOW, "====================");
			GivePlayerMoney(i, 2000);
			SetPlayerScore(i, level+1);
			return 1;
			}
		}
  		return 1;
}

That Works
Thanks you alot guys

Last edited by matute; 11/02/2012 at 06:39 PM.
matute is offline  
 

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
timer FireCat Help Archive 3 18/09/2010 07:05 PM
timer sggassasin Help Archive 19 18/07/2009 11:12 AM
this timer is 10 min gpclan Help Archive 3 13/07/2009 05:56 PM
Help with timer coole210 Help Archive 1 11/07/2009 09:03 AM
Help with timer dice7 Help Archive 3 11/04/2009 10:31 AM


All times are GMT. The time now is 06:01 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.