CMD:countdown(playerid,params[])
{
new string[4] = "4";
new countdown = strval(string);
CountTime = countdown;
if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);
if(sscanf(params, "i", countdown)) return Usage(playerid, "/countdown [time]");
TextDrawSetString(AnnText, CountTime);
TextDrawShowForAll(AnnText);
CountTimer = SetTimer("CountDown",1000,true);
return 1;
}
Okay, so im making a /countdown command, and im probably making it harder than it really should be. But im trying to convert the integer into a string or vise versa so i can use TextDrawSetString. But even when i strval i get an error on the TextDrawSetString line.
pawn Код:
|
CMD:countdown(playerid,params[])
{
new string[4];
new countdown = 4;
if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);
if(sscanf(params, "i", countdown)) return Usage(playerid, "/countdown [time]");
format(string,sizeof(string),"%d",countdown);
TextDrawSetString(AnnText, string);
TextDrawShowForAll(AnnText);
CountTimer = SetTimer("CountDown",1000,true);
return 1;
}
Try valstr. https://sampwiki.blast.hk/wiki/Valstr
|
CMD:countdown(playerid, params[])
{
if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);
new
digit = strval(params); // here we make what the player typed into an
// integer using strval
// isnull() checks if params is empty
// !strval(params) checks if it wasn't a number or they typed 0
if(isnull(params) || !strval(params))
{
return SendClientMessage(playerid, -1, "USAGE: /countdown [seconds]");
}
// valstr(digit) turns the variable digit
// into a string and returns it.
TextDrawSetString(AnnText, valstr(digit));
TextDrawShowForAll(AnnText);
CountTimer = SetTimer("CountDown",1000,true);
return 1;
}
(3692) : error 035: argument type mismatch (argument 1)
(3682) : warning 204: symbol is assigned a value that is never used: "digit"
TextDrawSetString(AnnText, valstr(digit));
CMD:countdown(playerid, params[])
{
if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);
new
digit = strval(params), // we can make more than one variable
seconds[8]; // by using a comma
if(isnull(params) || !digit)
{
return SendClientMessage(playerid, -1, "USAGE: /countdown [seconds]");
}
// this is the correct way to use valstr
// we store the amount of 'digits' into
// the string 'seconds'
valstr(seconds, digit);
TextDrawSetString(AnnText, seconds); // we then set the string of the textdraw to 'seconds'
TextDrawShowForAll(AnnText);
CountTimer = SetTimer("CountDown",1000,true);
return 1;
}
CMD:countdown(playerid, params[])
{
if(!IsAdmin(playerid, 1)) return ErrorMsg(playerid);
new
digit = strval(params);
if(isnull(params) || !digit)
{
return SendClientMessage(playerid, -1, "USAGE: /countdown [seconds]");
}
valstr(params, digit);
TextDrawSetString(AnnText, params);
TextDrawShowForAll(AnnText);
CountTimer = SetTimer("CountDown",1000,true);
return 1;
}