#1

Hello Guys, i have got this erorrs while iaam making my new Script today and i tried more thinngs but i can't fix it please can anyone help me ??
Код:
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;
}
ERRORS:
Код:
(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"
Reply
#2

Код:
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;
}
Reply
#3

Use sscanf 2.

PHP код:
CMD:datm(playeridparams[])
{
    if (!
IsPlayerAdmin(playerid)) 
        return 
SendClientMessage(playerid, -1"");
    new 
id;
    if(
sscanf(params"i"id))
            return 
SendClientMessage(playeridred"USAGE: /datm [ATM ID]");
    new 
atm_str[21];
    
format(atm_strsizeof(atm_str), "ATMs/atmid%d"id);
    if (!
dini_Exists(atm_str))
        return 
SendClientMessage(playeridred"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;

Reply
#4

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Use sscanf 2.

PHP код:
CMD:datm(playeridparams[])
{
    if (!
IsPlayerAdmin(playerid)) 
        return 
SendClientMessage(playerid, -1"");
    new 
id;
    if(
sscanf(params"i"id))
            return 
SendClientMessage(playeridred"USAGE: /datm [ATM ID]");
    new 
atm_str[21];
    
format(atm_strsizeof(atm_str), "ATMs/atmid%d"id);
    if (!
dini_Exists(atm_str))
        return 
SendClientMessage(playeridred"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;

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())
Reply
#5

Thnx all Proplem Solved
+repped
Reply
#6

Quote:
Originally Posted by Marricio
Посмотреть сообщение
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())
Not really.
Do a small test, you'd notice that sscanf (the plugin, not the pawn version) is actually faster than strval.
Also, in that situation, you'd have to use isnull, which also slows it down.
Which means sscanf is the better option:

PHP код:
new val1val2times 10000000str[] = "543";
new 
tick1 GetTickCount();
for (new 
0timesi++)
{
    if (
isnull(str)) continue;
    
val1 strval(str);
}
new 
tick2 GetTickCount();
for (new 
0timesi++)
{
    if (
sscanf(str"i"val2)) continue;
}
new 
tick3 GetTickCount();
printf("strval: %i\nsscanf: %i"tick2 tick1tick3 tick2);
printf("val1: %i\nval2: %i"val1val2);
-------- 
Results:
strval1954
sscanf
1554
strval
1935
sscanf
1561
strval
1930
sscanf
1543 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)