Making a timer.. -
StrikerZ - 06.10.2016
Hey there. I made /robstore command and a cooldown of 20 sec for it. But it can be abused and the player can farm scores in a specific store. So can i make a timer of 5 minutes of the store which was robbed?
Код:
CMD:robstore(playerid, params[])
{
if(Store1(playerid) || Store2(playerid) || Store3(playerid))
{
Robbingfix[playerid] = 1; // Don't remove this or robstore cmd will get bugged.
if(gTeam[playerid] == LSPD)
{
SCM(playerid, COLOR_RED, "[ERROR]: COPS can't perform this action!");
}
if(Robbing[playerid] == 0)
{
Robbing[playerid] = 1;
PlayerInfo[playerid][pWantedlevel] = 1;
switch(pWantedlevel)
{
case 0: SetPlayerColor(playerid, COLOR_WHITE);
case 1: SetPlayerColor(playerid, COLOR_YELLOW);
case 2: SetPlayerColor(playerid, COLOR_YELLOW);
case 3: SetPlayerColor(playerid, COLOR_YELLOW);
case 4: SetPlayerColor(playerid, COLOR_ORANGE);
case 5: SetPlayerColor(playerid, COLOR_ORANGE);
case 6: SetPlayerColor(playerid, COLOR_ORANGE);
case 7: SetPlayerColor(playerid, COLOR_ORANGE);
default: SetPlayerColor(playerid, COLOR_RED);
}
Robbingfix[playerid] = 1;
SetTimerEx("Robbing2", 45000, false, "i", playerid);
SendClientMessage(playerid, COLOR_YELLOW, "[INFORMATION]: Robbery has been started, please wait 45 seconds!");
}
if(Robbing[playerid] == 1 && Robbingfix[playerid] == 0)
{
SCM(playerid, -1, "NOTE: You need to wait 20 seconds before robbing another store.");
}
}
return 1;
}
Код:
stock Store1(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 384.808624,173.804992,1008.382812) || IsPlayerInRangeOfPoint(playerid, 7.0, 381.169189,-188.803024,1000.632812) || IsPlayerInRangeOfPoint(playerid, 7.0, 373.825653,-117.270904,1001.499511))
{
return 1;
}
return 0;
}
stock Store2(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 375.962463,-65.816848,1001.507812) || IsPlayerInRangeOfPoint(playerid, 7.0, 226.293991,-7.431529,1002.210937) || IsPlayerInRangeOfPoint(playerid, 7.0, -25.132598,-139.066986,1003.546875))
{
return 1;
}
return 0;
}
stock Store3(playerid)
{
if(IsPlayerInRangeOfPoint(playerid, 7.0, 226.293991,-7.431529,1002.210937) || IsPlayerInRangeOfPoint(playerid, 7.0, 226.293991,-7.431529,1002.210937))
{
return 1;
}
return 0;
}
Re: Making a timer.. -
JaKe Elite - 06.10.2016
gettime() + 300 = 5 minutes, Store this to a variable for example below #include you could add
PHP код:
new StoreHasBeenRobbed;
then when the store gets robbed
PHP код:
StoreHasBeenRobbed = gettime() + 300;
To check if the store is still not robbable
PHP код:
if (StoreHasBeenRobbed > gettime())
{
// Code
return 1;
}
Re: Making a timer.. -
X337 - 06.10.2016
You can add store variable and put last robbed time inside it, and check if store already robbed on last 5 minutes.
Example:
Код:
new StoreLastRobbed;
Put this under your robstore command
Код:
StoreLastRobbed = GetTickCount();
To check if store already robbed
Код:
if((GetTickCount() - StoreLastRobbed) < 5 * 60 * 1000) // 5*60*1000 is 5 minutes
SCM(playerid, "Store already robbed");
Note: You can set StoreLastRobbed as an array if you have many stores
Re: Making a timer.. -
StrikerZ - 06.10.2016
But see, im using the interiors of stores to make robstore command. Then if i store that, the corresponding interiors will also show that its been robbed.
Re: Making a timer.. -
JaKe Elite - 06.10.2016
Use virtual worlds, that is why virtual worlds are made for these to prevent conflictions.
Re: Making a timer.. -
StrikerZ - 06.10.2016
But wait... those virtual worlds, won't affect the interior at all? I mean like we do /gotoint [the interior of any type here] and if we put the xyz with wrong interior we won't see that interior with the correct interior listed in samp wiki
Re: Making a timer.. -
StrikerZ - 06.10.2016
But... i'm using store1 store2 store3 as the points which will trigger the robstore. I posted the store stocks also. They using inrangeofpoint and not interiors.. So i'm getting confused on how to do it
Re: Making a timer.. -
JaKe Elite - 06.10.2016
It won't affect the interior, it will just affect the world. Players in Virtual World #1 won't see players in Virtual World #0 (which is the default virtual world if you haven't placed any)
Here is how are you gonna check if player is in a virtual world (I am gonna modify one of your stocks)
PHP код:
if((IsPlayerInRangeOfPoint(playerid, 7.0, 384.808624,173.804992,1008.382812) && GetPlayerVirtualWorld(playerid) == /* value */) || /* Do the same here*/)
Re: Making a timer.. -
StrikerZ - 07.10.2016
Thanks but i got a srsly big problem. I used JakAdmin for the register/login and admin cmds. But... spawn money and scores won't be given. I transferred that filterscript into my gamemode successfully. Neither my SetPlayerColor works for LSPD. And how can i randomise the robbed money?
Re: Making a timer.. -
JaKe Elite - 08.10.2016
You should change the STARTING_SCORE and STARTING_MONEY from the JakAdmin itself since JakAdmin syncs the score and cash to it's data.
You could randomized the robbed money like this
PHP код:
new cashreward = random(50000)+10000; // randomizes from $1 to $49,999 and adds $10,000