SA-MP Forums Archive
Timer Help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Timer Help (/showthread.php?tid=610361)



Timer Help - CarRamper - 23.06.2016

Hello Guys Please Tell Me how i can make my register command To be available to player only if he had played on the server for 10 mins.remember i don't want that the Register dialog comes automatically after 10 mins

Here is my register command
Код:
CMD:register(playerid, params[])
    {
       new string [ 300 ];
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    format(string, sizeof(string), ""COL_WHITE"{0066FF}BilluGang Cops And Robbers\n\n{999999}New Registration\n{FFFFFF}Nick:{0099FF}%s\n\n{FFFFFF}Do {FF0000}Not {FFFFFF}Register Multiple Accounts\n{FFFFFF}Do {FF0000}Not {FFFFFF}Use The Game Password That You Use Elsewhere\n\nPlease {FFFF66}Enter Your Password {FFFFFF}For Your Account:", pName);
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"{FFFFFF}CnR {FFFFFF}Registration", string, "Register", "Cancel");
}



Re: Timer Help - Stinged - 23.06.2016

If the player is registering, what's the need for loading the ini file?
It doesn't even exist..

And to do your 10 minute thing, you need to do something like this:
Код:
new
    connectTime[MAX_PLAYERS];

public OnPlayerConnect(playerid)
{
    connectTime[playerid] = gettime();
    return 1;
}

CMD:register(playerid)
{
    if (gettime() - 10 * 60 < connectTime[playerid])
        return // You can't use this command right now..

    // Your register command
    return 1;
}



Re: Timer Help - CarRamper - 23.06.2016

Thanks A lot Stringed


Re: Timer Help - CarRamper - 23.06.2016

Getting Some Errors Here Are They
Код:
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\gamemodes\MWCNR.pwn(25) : warning 201: redefinition of constant/macro (symbol "SELECT_OBJECT_PLAYER_OBJECT")
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\pawno\include\YSI\internal\y_dohooks.inc(1720) : warning 201: redefinition of constant/macro (symbol "OnPlayerEnterCheckpoint")
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\pawno\include\YSI\internal\y_dohooks.inc(1783) : warning 201: redefinition of constant/macro (symbol "OnPlayerLeaveCheckpoint")
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\gamemodes\MWCNR.pwn(6071) : error 029: invalid expression, assumed zero
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\gamemodes\MWCNR.pwn(6071) : error 017: undefined symbol "string"
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\gamemodes\MWCNR.pwn(6071) : warning 215: expression has no effect
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\gamemodes\MWCNR.pwn(6071) : error 001: expected token: ";", but found "]"
C:\Users\Anurag\Desktop\Most Wanted Cops and Robbers v1.1\gamemodes\MWCNR.pwn(6071) : fatal error 107: too many error messages on one line



Re: Timer Help - CarRamper - 23.06.2016

Is This Correct gettinf error given above
Код:
CMD:register(playerid, params[])
    {
      if (gettime() - 10 * 60 < connectTime[playerid])
        return // You can't use this command right now..

new string[ 300 ];
    INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);

    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));

    format(string, sizeof(string), ""COL_WHITE"{0066FF}BilluGang Cops And Robbers\n\n{999999}New Registration\n{FFFFFF}Nick:{0099FF}%s\n\n{FFFFFF}Do {FF0000}Not {FFFFFF}Register Multiple Accounts\n{FFFFFF}Do {FF0000}Not {FFFFFF}Use The Game Password That You Use Elsewhere\n\nPlease {FFFF66}Enter Your Password {FFFFFF}For Your Account:", pName);
    ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"{FFFFFF}CnR {FFFFFF}Registration", string, "Register", "Cancel");
    return 1;
}



Re: Timer Help - Sjn - 23.06.2016

To make it less confusing, you can use NetStats_GetConnectedTime(); and you don't need to create any variables and clearing them etc...

Inside the command:
PHP код:
if (NetStats_GetConnectedTime(playerid) < (10 60 1000))
        return 
SendClientMessage(playerid, -1"10 minutes hasn't passed.");
// Your registration code bellow 



Re: Timer Help - Stinged - 23.06.2016

Why wasn't I aware of NetStats_GetConnectedTime..
Use Sjn's, delete the connectTime[MAX_PLAYERS] array.


Re: Timer Help - CarRamper - 23.06.2016

ok guys


Re: Timer Help - CarRamper - 23.06.2016

Where i have to use/put this code
Код:
if (NetStats_GetConnectedTime(playerid) < (10 * 60 * 1000)) 
        return SendClientMessage(playerid, -1, "10 minutes hasn't passed."); 

// Your registration code bellow



Re: Timer Help - Sjn - 23.06.2016

I already wrote in my earlier post, inside the command.

PHP код:
CMD:register(playeridparams[])
{
    if (
NetStats_GetConnectedTime(playerid) < (10 60 1000))
        return 
SendClientMessage(playerid, -1"Wait 10 minutes before registering.");
        
    new 
string 300 ];
    new 
pName[MAX_PLAYER_NAME];
    
GetPlayerName(playeridpNamesizeof(pName));
    
format(stringsizeof(string), ""COL_WHITE"{0066FF}BilluGang Cops And Robbers\n\n{999999}New Registration\n{FFFFFF}Nick:{0099FF}%s\n\n{FFFFFF}Do {FF0000}Not {FFFFFF}Register Multiple Accounts\n{FFFFFF}Do {FF0000}Not {FFFFFF}Use The Game Password That You Use Elsewhere\n\nPlease {FFFF66}Enter Your Password {FFFFFF}For Your Account:"pName);
    
ShowPlayerDialog(playeridDIALOG_REGISTERDIALOG_STYLE_INPUT""COL_WHITE"{FFFFFF}CnR {FFFFFF}Registration"string"Register""Cancel");
    return 
1;