SA-MP Forums Archive
Scripting error. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Scripting error. (/showthread.php?tid=597666)



Scripting error. - aimane65 - 03.01.2016

Hello,

I have got a small problem. It says in this line:
PHP код:
if(sscanf(params"0"valueSendClientMessage(playerid0xFFFFFFFF"USAGE: /giveall [Amount]"); return 1
I'm having this error:
Quote:

error 029: invalid expression, assumed zero




Re: Scripting error. - saffierr - 03.01.2016

Use the "i" or "d" parameters
PHP код:
if(sscanf(params"i"value)) SendClientMessage(playerid0xFFFFFFFF"USAGE: /giveall [Amount]); 



Re: Scripting error. - AndySedeyn - 03.01.2016

You're not closing your if-statement (missing bracket).
If your if-statement has more than one instruction, then I recommend putting them in a function block:

PHP код:
if(sscanf(params"i"value))
{
    
SendClientMessage(playerid0xFFFFFFFF"USAGE: /giveall [Amount]");
    return 
1;




Re: Scripting error. - aimane65 - 03.01.2016

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Use the "i" or "d" parameters
PHP код:
if(sscanf(params"i"value)) SendClientMessage(playerid0xFFFFFFFF"USAGE: /giveall [Amount]); 
Still got that error

Going to test yours now.


Re: Scripting error. - IceBilizard - 03.01.2016

PHP код:
if(sscanf(params"d"value)) return SendClientMessage(playerid0xFFFFFFFF"USAGE: /giveall [Amount]"); 



Re: Scripting error. - aimane65 - 03.01.2016

Still doesn't work..

Here is the whole command:

Quote:

{
new value;
if(!IsPlayerAdmin(playerid))
return 1;
if(sscanf(params, "i", value) SendClientMessage(playerid, 0xFFFFFFFF, "USAGE: /giveall [Amount]");
return 1;
for(new i=0; i<playerid; i++)
{
if(IsPlayerConnected(i))
{
GivePlayerMoney(i, value);
}
}
return 0;
}

can someone fix the whole command?


Re: Scripting error. - AndySedeyn - 03.01.2016

There's so much wrong with that command. Indent your code! That for-loop makes no sense unless playerid joined last. Use brackets.

I assume you're using ZCMD:
PHP код:
CMD:giveall(playeridparams[])
{
    if(!
IsPlayerAdmin(playerid)) {
        return 
1;
    }
    new 
value;
    if(
sscanf(params"i"value)) {
        
SendClientMessage(playerid0xFFFFFFFF"USAGE: /giveall [Amount]");
        return 
1;
    }
    for(new 
0GetPlayerPoolSize(); <= j++) {
        if(
IsPlayerConnected(i)) {
            
GivePlayerMoney(ivalue);
        }
    }
    return 
1;

Informative pages:
- GetPlayerPoolSize(): https://sampwiki.blast.hk/wiki/GetPlayerPoolSize
- sscanf: https://sampforum.blast.hk/showthread.php?tid=570927
- ZCMD: https://sampforum.blast.hk/showthread.php?tid=91354


Re: Scripting error. - saffierr - 03.01.2016

Do you actually realize that the cmd is available for everyone?
You should return 0; on the if is playeradmin line


Re: Scripting error. - AndySedeyn - 03.01.2016

Quote:
Originally Posted by saffierr
Посмотреть сообщение
Do you actually realize that the cmd is available for everyone?
You should return 0; on the if is playeradmin line
Returning 0 will tell the player that the command doesn't exist, while returning 1 does nothing other than flagging the command as 'successfully executed'. It still makes the command unusable.


Re: Scripting error. - aimane65 - 03.01.2016

PHP код:
        CMD:givecash(playeridparams[])
        {
        if(!
IsPlayerAdmin(playerid)) {

        return 
0;
        }

        new 
value;

        if(
sscanf(params"i"value))
        {

        
SendClientMessage(playerid0xFFFFFFFF"USAGE: /giveall [Amount]");
        return 
1;
        }
        for(new 
0GetPlayerPoolSize(); <= j++) {

        if(
IsPlayerConnected(i)) {

            
GivePlayerMoney(ivalue);
        }
    }
    return 
1;

I get error on this 2 lines:
PHP код:
CMD:givecash(playeridparams[]) 
PHP код:
if(sscanf(params"i"value)) 
Error it says:
Quote:

error 029: invalid expression, assumed zero

I don't get why it's still being like that