Zcmd Problem after updating
#1

Hello. When I updated my server to 0.3z RC5

I got an error on this code. I can't seem to find the problem. What causes it?

Errors:

Код:
warning 225: unreachable code
warning 217: loose indentation
 error 029: invalid expression, assumed zero
error 017: undefined symbol "cmd_pm"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line
PHP код:
CMD:pm(playerid, params[])
{
    new 
str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    if(
sscanf(params, "us", id, str2))
    {
        
SendClientMessage(playerid, 0xFFFF00C8, "Usage: /pm <id> <message>");
        return 
1;
    }
    if(!
IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFFFF00C8, "ERROR: Player not connected");
    if(
playerid == id) return SendClientMessage(playerid, 0xFFFF00C8, "ERROR: You cannot pm yourself!");
    {
        
GetPlayerName(playerid, Name1, sizeof(Name1));
        
GetPlayerName(id, Name2, sizeof(Name2));
        
format(str, sizeof(str), "PM To %s(ID %d): %s", Name2, id, str2);
        
SendClientMessage(playerid, 0xFFFF00C8, str);
        
format(str, sizeof(str), "PM From %s(ID %d): %s", Name1, playerid, str2);
        
SendClientMessage(id, 0xFFFF00C8, str);
    }
    return 
1;
} 
Reply
#2

Looks like you need to update ZCMD perhaps?
Also, I've noticed something with your code. For the sscanf line, it should be this:

pawn Код:
if(sscanf(params, "us[128]", id, str2))
128 can be replaced with whatever. This just means you are giving a string length. str and str2 should be put to something like 128 too.
Reply
#3

Quote:
Originally Posted by PrivatioBoni
Посмотреть сообщение
Looks like you need to update ZCMD perhaps?
Also, I've noticed something with your code. For the sscanf line, it should be this:

pawn Код:
if(sscanf(params, "us[128]", id, str2))
128 can be replaced with whatever. This just means you are giving a string length. str and str2 should be put to something like 128 too.
Thanks for the answer but I have the latest ZCMD. But they are above.

PHP код:
new str[256], str2[256], id, Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME]; 
Reply
#4

That's the definition of the variables, but you need to give the destination length on the sscanf line (as explained in post #2)

If you don't do this, your server log probably says something like "Strings without a destination length are deprecated" meaning that the /pm length will be tiny in-game. I'm not saying this is what is causing the problem, but since I have no real idea on how to fix the problem your 'actual problem', I'm sure the thing I said would help anyway.
Reply
#5

This happends to all my CMDS I made.
Reply
#6

Quote:
Originally Posted by Roddan
Посмотреть сообщение
This happends to all my CMDS I made.
Those error codes must have line numbers, Please post lines.
Reply
#7

Its line 328.

PHP код:
CMD:pm(playerid, params[]) 
Reply
#8

Make sure you have #include <zcmd> at the top of the script...
or you might not have the zcmd.inc in your include folder
Reply
#9

Quote:
Originally Posted by Hybris
Посмотреть сообщение
Make sure you have #include <zcmd> at the top of the script...
or you might not have the zcmd.inc in your include folder
Its included and the file is there.
Reply
#10

Uhm, If you have this command under any callback like OnPlayerCommandText, Just remove it and add it separately.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)