Samp PAYDAY per user.
#1

PHP код:
OngamemodeInit
SetTimer
("Payday"3600000true);
forward Payday();
public 
Payday()
{
   
    for(new 
i=0MAX_PLAYERSi++)
    {
        
pInfo[i][Money] += 400;
    }
    
SendClientMessageToAll(-1Heres your payday);
    return 
1;

My question is, how can I set this timer, per player in database?

I made this

enum Playerinfo
{
PayDay,
}


Payday row is set on MYSQL database.


and I don't want to make per hour for every player online, I want to set 60 minutes in mysql row, and when their minutes goes 0 it forwards payday + resets timer


and i don't know if payday script is made good
Reply
#2

add player's variables (for seconds example)
pInfo[playerid][PayDayTime] (for example)

so when player logins, you have to add one second timer for update (like this)
at the top of the script
PHP код:
new OneSecTimer[MAX_PLAYERS]; 
at LoginFunction >>
PHP код:
OneSecTimer[playerid] = SetTimerEx("OneSecondUpdate",1000,1,"i",playerid); 
at public OnPlayerDisconnect(...
PHP код:
KillTimer(OneSecTimer[playerid]); 
create new function called OneSecondUpdate(playerid)
PHP код:
forward OneSecondUpdate(playerid);
public 
OneSecondUpdate(playerid)
{
    
pInfo[playerid][PayDayTime]++; // increases the seconds with 1
    
if(pInfo[playerid][PayDayTime] == 3600//if the total amount of seconds = 3600, it means player played full hour, so here starts a payday.
    
{
        
//payday script here (for player, not for whole server)
        
pInfo[playerid][PayDayTime] = 0// to reset and countdown for next payday
    
}   
    return 
1;

also add this variable in your saving system and database (PayDayTime)
Reply
#3

Or something like this

PHP код:
public payday(playerid)
{
    if(
pInfo[playerid][Payday] == 0)
    {
        
KillTimer(playertimer[playerid]);
               
playertimer[playerid] = SetTimerEx("payday"1000true"i"playerid);
        
SendClientMessage(playeridCOLOR_RED"Here is your payday");
                
pInfo[i][Money] += 400
        
SaveStats(playerid);
    }
    else
    {
            
KillTimer(playertimer[playerid]);
    }
    return 
1;

?
Reply
#4

But better to restart timer inside his code:

PHP код:
forward function_name(playerid);
public 
function_name(playerid)
{
    
// code ...
    
variable_name[playerid] = SetTimerEx("function_name"1000false"d"playerid);
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)