How to store old value?
#1

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;
}
Reply
#2

try
pawn Код:
oldlimit = OldNukeTimer;
Reply
#3

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.
Reply
#4

Quote:
Originally Posted by mahdi499
Посмотреть сообщение
try
pawn Код:
oldlimit = OldNukeTimer;
eh,that is my question

how can i store value into oldnuketimer..
Reply
#5

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
Reply
#6

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;
}
Reply
#7

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
Reply
#8

Delete the old OldNukeTimer variable as you didn't do anything with it.
Reply
#9

need little help on this too

ApplyAnimation(i,"GRAFFITI","graffiti_Chkout",4.1, 1,1,1,1,1,1);

its not working
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)