How can I do time limit here ?
#1

How can I do time limit everytime for that rob cmd ?


Код:

CMD:robshop(playerid, params[])
{
    if(!IsAt247(playerid))
	{
        SendClientMessageEx(playerid, COLOR_GRAD2, "   You are not in a 24-7 for rob that!");
        return 1;
    }
     if (PlayerInfo[playerid][pScrewdriver] == 0) {
     SendClientMessageEx(playerid,COLOR_GREY,"   You need a screwdriver from a craftsman to break the cashbox!");
     return 1;
    }
    
   	{
	SendClientMessageToAll(COLOR_LIGHTRED, "* City Alert : Alarm ! Rob Shop ! By %s has been last seen at %s. !");
	}
    
    {
    GivePlayerCash(giveplayerid, 500);
    SendClientMessage(playerid, COLOR_RED, "You robbed the 24/7 for 500$.");
    return 1;
	}
Also I have these Errors , Dont confuse guyys , This errors only because this cmd and this is in different lines cause if I remove the cmd no errors so this is it , Fix it please and send me ty :

Код:
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3687) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3694) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3701) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3710) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3724) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3731) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3735) : error 017: undefined symbol "GivePlayerCash"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3738) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3745) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3752) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3767) : error 017: undefined symbol "GivePlayerCash"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3770) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3777) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3784) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3798) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3807) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3819) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3827) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3852) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3866) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3874) : error 017: undefined symbol "GivePlayerCash"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(3879) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(4042) : error 017: undefined symbol "GivePlayerCash"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(4104) : warning 219: local variable "targetid" shadows a variable at a preceding level
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(4219) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(4239) : error 017: undefined symbol "ProxDetector"
d:\Users\User\Desktop\SSS\Script[ONLY TO YOU]\AMRP\gamemodes\NQRP.pwn(4253) : error 017: undefined symbol "GivePlayerCash"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


26 Errors.
Reply
#2

Declare a global boolean.
At the end of your command, set the boolean to true and run a timer.
Inside the timer callback, reset the boolean variable's value to false.

Example:

pawn Код:
//globally
new
    bool:g_bRob
;

//command
g_bRob = true;
SetTimer( "RobShopResetTimer", YOUR_INTERVAL_HERE_IN_MS, false );

//bottom
forward RobShopResetTimer()
public RobShopResetTimer()
{
    if( g_bRob ) //in case you have a manual method for resetting
        g_bRob = false;
    return true;
}
You would then add an if-statement to check the boolean:

pawn Код:
if( g_bRob )
    return SendClientMessage( playerid, 0xFF0000AA, "[ERROR] This shop has recently been robbed. You can't rob this shop yet." );
Currently this is only working with one shop. To get it to work with more than one, use a boolean-array instead, and use a unique ID for each shop as the index.
Reply
#3

Thank u so much but how to fix the errors ?
Reply
#4

Quote:
Originally Posted by LarzI
Посмотреть сообщение
Declare a global boolean.
At the end of your command, set the boolean to true and run a timer.
Inside the timer callback.......
I don't think there is a real need of "timer" in here. You can simply do it with GetTickCount or gettime. Following is the command I fixed it and added the time limit with GetTickCount;

pawn Код:
#define SHOP_ROBBED_TIME        (60000) // 60 seconds (players will be able to rob it again after 60 secs) at top of the script

new ShopRobbedTicks; // new variable for counting ticks. (at top of the script)


CMD:robshop( playerid, params[ ] )
{
    if( !IsAt247( playerid ) ) return SendClientMessageEx( playerid, COLOR_GRAD2, "   You are not in a 24-7 for rob that!" );

    if ( PlayerInfo[ playerid ][ pScrewdriver ] == 0 ) return SendClientMessageEx( playerid, COLOR_GREY,"   You need a screwdriver from a craftsman to break the cashbox!" );
   
    new szStr[ 60 ];
    format( szStr, sizeof( szStr ), "Please wait for %d seconds before you rob again.", ( ShopRobbedTicks - GetTickCount( ) )/1000 );
    if( ShopRobbedTicks > GetTickCount( ) ) return SendClientMessage( playerid, COLOR_RED, szStr );
   
    SendClientMessageToAll( COLOR_LIGHTRED, "* City Alert : Alarm ! Rob Shop ! By %s has been last seen at %s. !" );

    GivePlayerCash( playerid , 500 );
    SendClientMessage( playerid, COLOR_RED, "You robbed the 24/7 for $500." );
   
    ShopRobbedTicks = GetTickCount( ) + SHOP_ROBBED_TIME; // in the cmd
   
    return 1;
}
ProxDetector, add this in the end of your script (I didn't script this):

pawn Код:
stock ProxDetector(Float:radi, playerid, str[],col1,col2,col3,col4,col5) {
new Float:P[3], Float:OP[3], Float:TP[3];
GetPlayerPos(playerid, OP[0], OP[1], OP[2]);
for(new i; i < MAX_PLAYERS; i++) {
GetPlayerPos(i, P[0], P[1], P[2]);
TP[0] = (OP[0]-P[0]);
TP[1] = (OP[1]-P[1]);
TP[2] = (OP[2]-P[2]);
if(((TP[0] < radi/16) && (TP[0] > -radi/16)) && ((TP[1] < radi/16) && (TP[1] > -radi/16)) && ((TP[2] < radi/16) && (TP[2] > -radi/16))) SendClientMessage(i, col1, str);
else if (((TP[0] < radi/8) && (TP[0] > -radi/8)) && ((TP[1] < radi/8) && (TP[1] > -radi/8)) && ((TP[2] < radi/8) && (TP[2] > -radi/8))) SendClientMessage(i, col2, str);
else if (((TP[0] < radi/4) && (TP[0] > -radi/4)) && ((TP[1] < radi/4) && (TP[1] > -radi/4)) && ((TP[2] < radi/4) && (TP[2] > -radi/4))) SendClientMessage(i, col3, str);
else if (((TP[0] < radi/2) && (TP[0] > -radi/2)) && ((TP[1] < radi/2) && (TP[1] > -radi/2)) && ((TP[2] < radi/2) && (TP[2] > -radi/2))) SendClientMessage(i, col4, str);
else if (((TP[0] < radi) && (TP[0] > -radi)) && ((TP[1] < radi) && (TP[1] > -radi)) && ((TP[2] < radi) && (TP[2] > -radi))) SendClientMessage(i, col5, str);
}
return 1;
}
GivePlayerCash:, change it to GivePlayerMoney

Regards FalconX
Reply
#5

Quote:
Originally Posted by FalconX
Посмотреть сообщение
I don't think there is a real need of "timer" in here. You can simply do it with GetTickCount or gettime.
True.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)