How to store old value? -
Nabster - 21.02.2015
I want to display old cooldown time
Код:
CMD:setnuke(playerid, params[])
{
if(PInfo[playerid][Level] < 5)
return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 5 to set nuke cooldown.");
new string[128];
new oldlimit;
new newlimit;
if(sscanf(params,"i",newlimit))
return SendClientMessage(playerid, COLOR_RED, "USAGE: /setnuke [Cooldown]");
OldNukeTimer = oldlimit;
NukeTimer = newlimit;
new pName[MAX_PLAYER_NAME];
CMDMessageToAdmins(playerid,"SETNUKE");
GetPlayerName(playerid, pName, sizeof(pName));
format(string,sizeof(string),"Administrator %s(%d) has changed the nuke cooldown from %i to %i seconds.",pName,playerid,oldlimit,newlimit);
SendClientMessageToAll(COLOR_DARKORCHID, string);
return 1;
}
Re: How to store old value? -
mahdi499 - 21.02.2015
try
Re: How to store old value? -
CalvinC - 21.02.2015
You're setting OldNukeTimer to oldlimit, but you didn't define oldlimit to do anything before, you just created it.
Either use OldNukeTimer in your string, or set oldlimit to OldNukeTimer instead, although i don't think there's a reason to use oldlimit as using OldNukeTimer in your string should be fine.
Re: How to store old value? -
Nabster - 21.02.2015
Quote:
Originally Posted by mahdi499
|
eh,that is my question
how can i store value into oldnuketimer..
Re: How to store old value? -
mahdi499 - 21.02.2015
That's how you do it, i gave you the soloution the difference between mine and the one you had. is that in my code you set the OLD TIMER value to the nuketimer value but in your code, you change the nuketimervalue to the oldtimer value which is 0
Re: How to store old value? -
CalvinC - 21.02.2015
Quote:
Originally Posted by Nabster
eh,that is my question
how can i store value into oldnuketimer..
|
If you don't do anything with your OldNukeTimer, you can store the "NukeTimer" value in your "OldNukeTimer" value before you change it.
pawn Код:
CMD:setnuke(playerid, params[])
{
if(PInfo[playerid][Level] < 5)
return SendClientMessage(playerid,STEALTH_BLUE,"You need to be level 5 to set nuke cooldown.");
new string[128];
new OldNukeTimer = NukeTimer;
new newlimit;
if(sscanf(params,"i",newlimit))
return SendClientMessage(playerid, COLOR_RED, "USAGE: /setnuke [Cooldown]");
NukeTimer = newlimit;
new pName[MAX_PLAYER_NAME];
CMDMessageToAdmins(playerid,"SETNUKE");
GetPlayerName(playerid, pName, sizeof(pName));
format(string,sizeof(string),"Administrator %s(%d) has changed the nuke cooldown from %i to %i seconds.",pName,playerid,OldNukeTimer,newlimit);
SendClientMessageToAll(COLOR_DARKORCHID, string);
return 1;
}
Re: How to store old value? -
Nabster - 21.02.2015
warning 219: local variable "OldNukeTimer" shadows a variable at a preceding level
EDIT: Fixed,i declared oldnuketimer globally before and was trying to store value in it thats why it never worked
Re: How to store old value? -
CalvinC - 21.02.2015
Delete the old OldNukeTimer variable as you didn't do anything with it.
Re: How to store old value? -
Nabster - 21.02.2015
need little help on this too
ApplyAnimation(i,"GRAFFITI","graffiti_Chkout",4.1, 1,1,1,1,1,1);
its not working