Timer Help
#1

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");
}
Reply
#2

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;
}
Reply
#3

Thanks A lot Stringed
Reply
#4

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
Reply
#5

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;
}
Reply
#6

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 
Reply
#7

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

ok guys
Reply
#9

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
Reply
#10

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;

Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)