Scripting error.
#1

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

Reply
#2

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

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;

Reply
#4

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

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

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

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

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

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)