SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 16/04/2018, 02:20 PM   #1
Zeus666
Gangsta
 
Join Date: Mar 2015
Posts: 507
Reputation: 42
Default Samp PAYDAY per user.

PHP Code:
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
Zeus666 is offline   Reply With Quote
Old 16/04/2018, 02:26 PM   #2
Mugala
Gangsta
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: behind u
Posts: 645
Reputation: 30
Default Re: Samp PAYDAY per user.

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 Code:
new OneSecTimer[MAX_PLAYERS]; 
at LoginFunction >>
PHP Code:
OneSecTimer[playerid] = SetTimerEx("OneSecondUpdate",1000,1,"i",playerid); 
at public OnPlayerDisconnect(...
PHP Code:
KillTimer(OneSecTimer[playerid]); 
create new function called OneSecondUpdate(playerid)
PHP Code:
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)
__________________
here to help
Mugala is offline   Reply With Quote
Old 16/04/2018, 02:27 PM   #3
Zeus666
Gangsta
 
Join Date: Mar 2015
Posts: 507
Reputation: 42
Default Re: Samp PAYDAY per user.

Or something like this

PHP Code:
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;

?
Zeus666 is offline   Reply With Quote
Old 16/04/2018, 02:46 PM   #4
Twixxx
Little Clucker
 
Twixxx's Avatar
 
Join Date: Jun 2017
Posts: 8
Reputation: 6
Default Re: Samp PAYDAY per user.

But better to restart timer inside his code:

PHP Code:
forward function_name(playerid);
public 
function_name(playerid)
{
    
// code ...

    
variable_name[playerid] = SetTimerEx("function_name"1000false"d"playerid);
    return 
1;

Twixxx is offline   Reply With Quote
Reply

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
[Pedido] Sistema de payday quando vc e vip de dar 3 leveis a cada payday didimk157 Português/Portuguese 8 26/06/2017 02:05 AM
How can i increase the payday on My Server?? Included Payday Code Samieastwood Server Support 4 12/08/2013 06:41 AM
SAMP User File doesn't appear. Hudsonn Client Support 2 11/08/2013 06:03 PM
[Ajuda] Payday fechando samp-server Lós Português/Portuguese 15 13/02/2011 01:56 AM
Looking for the SAMP user Chris_Hawk cstatus94 General 8 13/12/2010 02:46 PM


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


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