Can somone help me
#1

Can somone help me how to make 30 sec timer .. Somone use the command and others need to wait 30 sec before using the cmd ..
pawn Код:
if(strcmp(cmd, "/oglas", true) == 0 || strcmp(cmd, "/oglas", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Neste logirani !");
                return 1;
            }
            if(PlayerInfo[playerid][pLevel] < 3)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Mora da ste level 3 za da pisuvate oglas !");
                return 1;
            }
            if(!PlayerToPoint(10.0,playerid,-2239.4780,130.4675,1035.4141))
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Neste vo Oglasnik !");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_RED, "Koristi: /oglas [ text]");
                return 1;
            }
            if ((!adds) && (PlayerInfo[playerid][pAdmin] < 1))
            {
                format(string, sizeof(string), "{FF0000}GRESKA:{FFFFFF}Ve molime pocekajte 10 sekundi za da napisete oglas.", (addtimer/10000));
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;

            }
            new payout = idx * 200;
            if(GetPlayerMoney(playerid) < payout)
            {
                format(string, sizeof(string), "Iskoristivte %d Bukvi koj cinat $%d, Nemate dovolno.", offset, payout);
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;
            }
            GivePlayerMoney(playerid, - payout);
            SBizzInfo[7][sbTill] += payout;
            ExtortionSBiz(7, payout);
            format(string, sizeof(string), "{37F906}[OGLAS]: %s,{F3FF02}Kontakt: %s Mobilen: %d",  result, sendername, PlayerInfo[playerid][pPnumber]);
            OOCNews(TEAM_GROVE_COLOR,string);
            format(string, sizeof(string), "~r~Plativte $%d~n~~w~Poraka se sostoi od: %d Bukvi", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 1);
            if (PlayerInfo[playerid][pAdmin] < 1){SetTimer("AddsOn", addtimer, 0);adds = 0;}
        }
        return 1;
    }
Reply
#2

Try with GetTickCount, for example:


PHP код:
if(GetTickCount()-SyncCD[playerid]<2800)return 0
Youґve gotta set a Variable by yourself (SyncCD[playerid] in this Line)


Do it like this:

PHP код:
stock Sync(playerid)
{
    if(
GetTickCount()-SyncCD[playerid]<2800)return 0//If the TickCount isnt finished it wont do anything
    
else
    {
           
//DoSomethingHere
           
return 1;
        } 
Try to add this into your code with your own variables, it wont be very helpfull if I add it for you cuz you wont learn how to use it then


If you still dont know how to do it let me know
Reply
#3

Quote:
Originally Posted by Saize
Посмотреть сообщение
Try with GetTickCount, for example:


PHP код:
if(GetTickCount()-SyncCD[playerid]<2800)return 0
Youґve gotta set a Variable by yourself (SyncCD[playerid] in this Line)


Do it like this:

PHP код:
stock Sync(playerid)
{
    if(
GetTickCount()-SyncCD[playerid]<2800)return 0//If the TickCount isnt finished it wont do anything
    
else
    {
           
//DoSomethingHere
           
return 1;
        } 
Try to add this into your code with your own variables, it wont be very helpfull if I add it for you cuz you wont learn how to use it then


If you still dont know how to do it let me know
No idea how to add it Never worked with timers
Reply
#4

Код:
SetTimerEx("<TimerName>", <time (1s is 1000)>, <boolean(can be called multiple times)>, "i", playerid<playerthatgetsthis>);
Then, out of that command or whatever, forwarding the <TimerName>and using it as a callback makes you able to put codes in there, so once you entered that ^^ up there, do the following.

Код:
forward <TimerName>(playerid);
public <TimerName>(playerid);
{
    // insert code here that you want to put, this code appears after the timer has passed, so
    SendClientMessage(playerid, -1, "The timer has passed and you may report once more!.");
return 1;
}

Hope this helps you with it, I don't understand timers so well either, so apologies if there are mistakes!

Actually I didn't read yours very well, so here's one I use for my own reports -----------

Add this to the top first:
Код:
new PlayerHasReported[MAX_PLAYERS]; // this is just a thing that indicates if the player has reported
Код:
if(PlayerHasReported[playerid] == 1) // this gets if the player has /report'ed in the last 10 seconds
        {
            SendClientMessage(playerid, COLOR_GREY, "   Wait 10 seconds after sending a next report ! "); // self explainatory
            return 1;
        }
// code here
SetTimerEx("ReportReset", 10000, false, "i", playerid); // timer that stops you from reporting again in 10 seconds
PlayerHasReported[playerid] = 1; // this is to say that they have reported in the last 10 seconds
Once you made that, we can go to forwarding
Код:
forward ReportReset(playerid);
public ReportReset(playerid)
{
	if(IsPlayerConnected(playerid)) // checks if player is connected
	{
	    if(PlayerHasReported[playerid] == 1) PlayerHasReported[playerid] = 0; // if player's 10 seconds cooldown is over then it allows them to report again
	}
}
I hope this will do the trick

Sorry if I made any mistakes, I just woke up.
Reply
#5

Quote:
Originally Posted by JakeHunter1
Посмотреть сообщение
No idea how to add it Never worked with timers
can you add it i need it fast ..
Reply
#6

Quote:
Originally Posted by JakeHunter1
Посмотреть сообщение
can you add it i need it fast ..
Код:
if(strcmp(cmd, "/oglas", true) == 0 || strcmp(cmd, "/oglas", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Neste logirani !");
                return 1;
            }
            if(PlayerInfo[playerid][pLevel] < 3)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Mora da ste level 3 za da pisuvate oglas !");
                return 1;
            }
            if(!PlayerToPoint(10.0,playerid,-2239.4780,130.4675,1035.4141))
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Neste vo Oglasnik !");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_RED, "Koristi: /oglas [ text]");
                return 1;
            }
            if ((!adds) && (PlayerInfo[playerid][pAdmin] < 1))[/COLOR])
            {
                format(string, sizeof(string), "{FF0000}GRESKA:{FFFFFF}Ve molime pocekajte 10 sekundi za da napisete oglas.", (addtimer/10000));
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;

            }
            new payout = idx * 200;
            if(GetPlayerMoney(playerid) < payout)
            {
                format(string, sizeof(string), "Iskoristivte %d Bukvi koj cinat $%d, Nemate dovolno.", offset, payout);
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;
            }
            GivePlayerMoney(playerid, - payout);
            SBizzInfo[7][sbTill] += payout;
            ExtortionSBiz(7, payout);
            format(string, sizeof(string), "{37F906}[OGLAS]: %s,{F3FF02}Kontakt: %s Mobilen: %d",  result, sendername, PlayerInfo[playerid][pPnumber]);
            OOCNews(TEAM_GROVE_COLOR,string);
            format(string, sizeof(string), "~r~Plativte $%d~n~~w~Poraka se sostoi od: %d Bukvi", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 1);
            if (PlayerInfo[playerid][pAdmin] < 1);
            SetTimerEx("AddsReset", 30000, false, "i", playerid);

            
        }
        return 1;
    }

forward AddsReset(playerid)
public AddsReset(playerid)
{
	if(IsPlayerConnected(playerid))
	{
	    if(adds[playerid] == 1) adds[playerid] = 0; // not sure about this, edit to your own things if i did it wrong
	}
}
I suppose "adds" is your name for it?

I hope this'll do the trick, I don't quite get your language.
Reply
#7

Quote:
Originally Posted by JaydenJason
Посмотреть сообщение
Код:
if(strcmp(cmd, "/oglas", true) == 0 || strcmp(cmd, "/oglas", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(gPlayerLogged[playerid] == 0)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Neste logirani !");
                return 1;
            }
            if(PlayerInfo[playerid][pLevel] < 3)
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Mora da ste level 3 za da pisuvate oglas !");
                return 1;
            }
            if(!PlayerToPoint(10.0,playerid,-2239.4780,130.4675,1035.4141))
            {
                SendClientMessage(playerid, COLOR_YELLOW, "Neste vo Oglasnik !");
                return 1;
            }
            GetPlayerName(playerid, sendername, sizeof(sendername));
            new length = strlen(cmdtext);
            while ((idx < length) && (cmdtext[idx] <= ' '))
            {
                idx++;
            }
            new offset = idx;
            new result[64];
            while ((idx < length) && ((idx - offset) < (sizeof(result) - 1)))
            {
                result[idx - offset] = cmdtext[idx];
                idx++;
            }
            result[idx - offset] = EOS;
            if(!strlen(result))
            {
                SendClientMessage(playerid, COLOR_RED, "Koristi: /oglas [ text]");
                return 1;
            }
            if ((!adds) && (PlayerInfo[playerid][pAdmin] < 1))[/COLOR])
            {
                format(string, sizeof(string), "{FF0000}GRESKA:{FFFFFF}Ve molime pocekajte 10 sekundi za da napisete oglas.", (addtimer/10000));
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;

            }
            new payout = idx * 200;
            if(GetPlayerMoney(playerid) < payout)
            {
                format(string, sizeof(string), "Iskoristivte %d Bukvi koj cinat $%d, Nemate dovolno.", offset, payout);
                SendClientMessage(playerid, COLOR_WHITE, string);
                return 1;
            }
            GivePlayerMoney(playerid, - payout);
            SBizzInfo[7][sbTill] += payout;
            ExtortionSBiz(7, payout);
            format(string, sizeof(string), "{37F906}[OGLAS]: %s,{F3FF02}Kontakt: %s Mobilen: %d",  result, sendername, PlayerInfo[playerid][pPnumber]);
            OOCNews(TEAM_GROVE_COLOR,string);
            format(string, sizeof(string), "~r~Plativte $%d~n~~w~Poraka se sostoi od: %d Bukvi", payout, idx);
            GameTextForPlayer(playerid, string, 5000, 1);
            if (PlayerInfo[playerid][pAdmin] < 1);
            SetTimerEx("AddsReset", 30000, false, "i", playerid);

            
        }
        return 1;
    }

forward AddsReset(playerid)
public AddsReset(playerid)
{
	if(IsPlayerConnected(playerid))
	{
	    if(adds[playerid] == 1) adds[playerid] = 0; // not sure about this, edit to your own things if i did it wrong
	}
}
I suppose "adds" is your name for it?

I hope this'll do the trick, I don't quite get your language.
Thanks ..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)