Countdown problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Countdown problem (
/showthread.php?tid=638609)
Countdown problem -
Kyriee - 03.08.2017
Well I got countdown problem. when person do /wcd it should count down but it stuck at 42. So here are scripts
Код:
new WCDVar = 4;
new WCDTimer;
CMD:wcd(playerid,params[])
{
if(PlayerInfo[playerid][W] >= 1)
{
for(new i = 0; i < MAX_PLAYERS; i++)
if(PlayerInfo[i][W] >= 1) {
WCDTimer = SetTimer("WCD", 1000, true);
} return CMDMessageToW(playerid,"WCountDown");
}
return 1;
}
forward WCD();
public WCD()
{
WCDVar--;
new str[128];
if(WCDVar == 0)
{
KillTimer(WCDTimer);
WCDVar = 4;
}
else
{
format(str, sizeof(str), "%d", WCDTimer);
GameTextForAll(str, 1000, 6);
}
return 1;
}
Thank you for help
Re: Countdown problem -
Arbico - 03.08.2017
Do you want it to count for that player only or all players on the server?
Re: Countdown problem -
Kyriee - 04.08.2017
Quote:
Originally Posted by Arbico
Do you want it to count for that player only or all players on the server?
|
To all players with W rank. But it isnt problem. Just need solution how to make it counts down. Not to be stuck at 42.
Re: Countdown problem -
Kyriee - 05.08.2017
Bump
Re: Countdown problem -
Kyriee - 07.08.2017
Cmon guys
Re: Countdown problem -
Kane - 07.08.2017
Код:
format(str, sizeof(str), "%d", WCDTimer);
You're showing WCDTimer for the cooldown instead of WCDVar. This is most likely your problem but there are more than one errors in your code. For example:
You're using GameTextForAll but in the command you check for specific players. Your codes redundant and half of it is irrelevant.
Make WCDTimer a player variable.
PHP код:
new WCDTimer[MAX_PLAYERS];
Instead of SetTimer, we'll use SetTimerEx to define the players.
PHP код:
CMD:wcd(playerid, params[])
{
if (!PlayerInfo[playerid][W])
return SendClientMessage(playerid, -1, "You don't have permission to use this.");
for (new i = 0; i < MAX_PLAYERS; i++){
if (PlayerInfo[i][W]){
WCDTimer[i] = SetTimerEx("WCD", 1000, true, "i", i);
}
}
CMDMessageToW(playerid, "WCountDown");
return 1;
}
Change your public function:
PHP код:
public WCD(playerid)
{
WCDVar--;
new str[60];
if(WCDVar == 0)
{
KillTimer(WCDTimer[playerid]);
WCDVar = 4;
}
else
{
format (str, sizeof(str), "%d", WCDVar);
GameTextForPlayer(playerid, str, 3000, 6);
}
return 1;
}
Re: Countdown problem -
Kyriee - 17.08.2017
Quote:
Originally Posted by Arthur Kane
Код:
format(str, sizeof(str), "%d", WCDTimer);
You're showing WCDTimer for the cooldown instead of WCDVar. This is most likely your problem but there are more than one errors in your code. For example:
You're using GameTextForAll but in the command you check for specific players. Your codes redundant and half of it is irrelevant.
Make WCDTimer a player variable.
PHP код:
new WCDTimer[MAX_PLAYERS];
Instead of SetTimer, we'll use SetTimerEx to define the players.
PHP код:
CMD:wcd(playerid, params[])
{
if (!PlayerInfo[playerid][W])
return SendClientMessage(playerid, -1, "You don't have permission to use this.");
for (new i = 0; i < MAX_PLAYERS; i++){
if (PlayerInfo[i][W]){
WCDTimer[i] = SetTimerEx("WCD", 1000, true, "i", i);
}
}
CMDMessageToW(playerid, "WCountDown");
return 1;
}
Change your public function:
PHP код:
public WCD(playerid)
{
WCDVar--;
new str[60];
if(WCDVar == 0)
{
KillTimer(WCDTimer[playerid]);
WCDVar = 4;
}
else
{
format (str, sizeof(str), "%d", WCDVar);
GameTextForPlayer(playerid, str, 3000, 6);
}
return 1;
}
|
Will try it tonight, hope it will work.