[HELP] SetTimer
#1

pawn Код:
SetTimer("Message",inputtext,false); //inputtex - There i should put the time
pawn Код:
argument type mismatch (argument 2)
And do you know about any good tutorials about timer? OFC i have searched, but dont find any ill understand :P
Reply
#2

I think you had to check if inputtext is numeric, because I guess it would work just with numeric values. So:
pawn Код:
stock IsNumeric(string[])
{
    for (new i = 0, j = strlen(string); i < j; i++)
    {
        if (string[i] > '9' || string[i] < '0') return 0;
    }
    return 1;
}
pawn Код:
If(IsNumeric(inputtext)) return continue; else break; // Never used continue or break, so if dont work, switch break for return false and continue for return true;
Reply
#3

what u mean? xD

Change:
pawn Код:
SetTimer("Message",inputtext ,false);
TO
pawn Код:
If(IsNumeric(inputtext)) return continue; else break;


and is is possible to change the "1000" (1 sec) to 1 = 1 minute
like: instead of typing "1000", you can just type 1 (1=minute)
Reply
#4

Quote:
Originally Posted by Larsey123IsMe
Посмотреть сообщение
what u mean? xD

Change:
pawn Код:
SetTimer("Message",inputtext ,false);
TO
pawn Код:
If(IsNumeric(inputtext)) return continue; else break;


and is is possible to change the "1000" (1 sec) to 1 = 1 minute
like: instead of typing "1000", you can just type 1 (1=minute)
This about typing 1 instead of 1000 I dont have knowledge enough yet. About my first answer, I mean for you do this check on the Input dialog, and detect if value is numeric or normal.
Reply
#5

Example:

pawn Код:
new adminPlayer[20];
forward BanHim(playerid);
pawn Код:
public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
    if(IsPlayerAdmin(playerid))
    {
        ShowPlayerDialog(playerid, 1, DIALOG_STYLE_LIST, "Admin Menu?", "Ban Player (Minutes)", "ok", "Cancel");
        adminPlayer[playerid] = clickedplayerid;
    }
    return 0;
}
pawn Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(response)
    {
    switch(dialogid)
        {
        case 1:
            {
            switch(listitem)
                {
                    case 0: ShowPlayerDialog(playerid, 2, DIALOG_STYLE_INPUT, "Admin Menu", "Enter the time to the player get banned", "Ban", "Cancel");
                }
            }
            case 2:
            {
                new playerwhogetbanned[MAX_PLAYER_NAME], string[44];
                GetPlayerName(adminPlayer[playerid], playerwhogetbanned, sizeof(playerwhogetbanned));
                format(string, sizeof(string), "Muhahah %s will be banned in %d mins",playerwhogetbanned, inputtext);
                SendClientMessageToAll(0xFFFF00AA, string);
                SetTimer("BanHim",inputtext ,false); //Inputtext = Minutes, not milliseconds
                adminPlayer[playerid] = 0;
            }
       }
   }
return 1;
}
pawn Код:
public BanHim(playerid)
{
    Ban(adminPlayer[playerid]);
}
Reply
#6

Oh:

1000 mili = 1min. Type 1000 instead 1min just

Change the case 2: to:

pawn Код:
case 2:
            {
                new playerwhogetbanned[MAX_PLAYER_NAME], string[44];
                GetPlayerName(adminPlayer[playerid], playerwhogetbanned, sizeof(playerwhogetbanned));
                format(string, sizeof(string), "Muhahah %s will be banned in %d mins",playerwhogetbanned, inputtext);
                SendClientMessageToAll(0xFFFF00AA, string);
                adminPlayer[playerid] = 0;
                if(IsNumeric(inputtext))
                {
                SetTimer("BanHim",inputtext ,false); //Inputtext = Minutes, not milliseconds
                }
               
            }
Do not forget to add that stock befor'
Reply
#7

thx, but
it still gives me that error

pawn Код:
Example.pwn(38) : error 035: argument type mismatch (argument 2)
pawn Код:
SetTimer("BanHim",inputtext ,false); //At this line
Reply
#8

Quote:
Originally Posted by Larsey123IsMe
Посмотреть сообщение
thx, but
it still gives me that error

pawn Код:
Example.pwn(38) : error 035: argument type mismatch (argument 2)
pawn Код:
SetTimer("BanHim",inputtext ,false); //At this line
SetTimerEx("BanHim", 1000, false, "i", strval(inputtext));
Reply
#9

pawn Код:
SetTimer("lol",inputtext[0],false);
Tried and works. Sorry if I am so dumb lol
Reply
#10

Quote:
Originally Posted by blackwave
Посмотреть сообщение
1000 mili = 1min. Type 1000 instead 1min just
1000ms = 1 second not minute.
Quote:
Originally Posted by blackwave
Посмотреть сообщение
pawn Код:
SetTimer("lol",inputtext[0],false);
Tried and works. Sorry if I am so dumb lol
I'm surprised if that works because inputtext is a string you would need to use "strval(inputtext)" as mentioned in an earlier post.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)