CMD:datm(playerid,params[])
{
new str1[255], atm[250];
if(IsPlayerAdmin(playerid)) {
if(isnull(params)) return SendClientMessage(playerid, red, "USAGE: /datm [ATM ID]");
format(atm, sizeof(atm), "ATMs/atmid%d",params);
if(dini_Exists(atm))
{
dini_Remove(atm);
DestroyDynamicObject(ATMInfo[params][aObje]);
catm-=1;
UpdateDynamic3DTextLabelText(ATMInfo[params][aLabel],0xFF0000FF,"");
DestroyDynamicMapIcon(ATMInfo[params][aMicon]);
} else SendClientMessage(playerid, red, "ERROR: There's no ATM Pranch Exists on our Database with this ID")
} else SendClientMessage(playerid, -1, "");
return 1;
}
(51749) : error 033: array must be indexed (variable "params") (51751) : error 033: array must be indexed (variable "params") (51752) : error 033: array must be indexed (variable "params") (51754) : error 001: expected token: ";", but found "}" (51742) : warning 204: symbol is assigned a value that is never used: "str1"
CMD:datm(playerid,params[])
{
new atm[250], value = strval(params);
if(IsPlayerAdmin(playerid)) {
if(isnull(value)) return SendClientMessage(playerid, red, "USAGE: /datm [ATM ID]");
format(atm, sizeof(atm), "ATMs/atmid%d",value);
if(dini_Exists(atm))
{
dini_Remove(atm);
DestroyDynamicObject(ATMInfo[value][aObje]);
catm-=1;
UpdateDynamic3DTextLabelText(ATMInfo[value][aLabel],0xFF0000FF,"");
DestroyDynamicMapIcon(ATMInfo[value][aMicon]);
} else SendClientMessage(playerid, red, "ERROR: There's no ATM Pranch Exists on our Database with this ID");
} else SendClientMessage(playerid, -1, "");
return 1;
}
CMD:datm(playerid, params[])
{
if (!IsPlayerAdmin(playerid))
return SendClientMessage(playerid, -1, "");
new id;
if(sscanf(params, "i", id))
return SendClientMessage(playerid, red, "USAGE: /datm [ATM ID]");
new atm_str[21];
format(atm_str, sizeof(atm_str), "ATMs/atmid%d", id);
if (!dini_Exists(atm_str))
return SendClientMessage(playerid, red, "ERROR: There's no ATM Pranch Exists on our Database with this ID");
dini_Remove(atm_str);
DestroyDynamicObject(ATMInfo[params][aObje]);
catm-=1;
UpdateDynamic3DTextLabelText(ATMInfo[params][aLabel],0xFF0000FF,"");
DestroyDynamicMapIcon(ATMInfo[params][aMicon]);
return 1;
}
|
Use sscanf 2.
PHP код:
|
|
That's not the best solution, it isn't recommended to use sscanf when you're handling a single parameter. To solve the OP issue, you need to start to address the variable as an integer. (using strval())
|
new val1, val2, times = 10000000, str[] = "543";
new tick1 = GetTickCount();
for (new i = 0; i < times; i++)
{
if (isnull(str)) continue;
val1 = strval(str);
}
new tick2 = GetTickCount();
for (new i = 0; i < times; i++)
{
if (sscanf(str, "i", val2)) continue;
}
new tick3 = GetTickCount();
printf("strval: %i\nsscanf: %i", tick2 - tick1, tick3 - tick2);
printf("val1: %i\nval2: %i", val1, val2);
-------- Results:
strval: 1954
sscanf: 1554
strval: 1935
sscanf: 1561
strval: 1930
sscanf: 1543