PM errors
#1

I'm new to scripting. I was making /pm cmd. this is the code:-
PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
 if (
strcmp("/pm"cmdtexttrue10) == 0)
    {
    new 
str[128],id,pname[MAX_PLAYER_NAME];
    if(
sscanf(params"us"idparams)) SendClientMessage(playerid0xFF0000FF"Usage: /pm <id> <message>");
    else if(
id == INVALID_PLAYER_IDSendClientMessage(playerid0xFF0000FF"ERROR: Player not connected");
    if(
playerid == idSendClientMessage(playerid0xFF0000FF"ERROR: You cannot pm yourself!");
    else
    {
        
GetPlayerName(idpnamesizeof(pname));
        
format(strsizeof(str), "PM To %s(ID %d): %s"pnameidparams);
        
SendClientMessage(playerid0xFF0000FFstr);
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(strsizeof(str), "PM From %s(ID %d): %s"pnameplayeridparams);
        
SendClientMessage(id0xFF0000FFstr);
    }
    return 
1;
}
    return 
0;

These are the errors I'm getting:-
PHP код:
D:\myownscript\gamemodes\fgrp.pwn(164) : error 017undefined symbol "params"
D:\myownscript\gamemodes\fgrp.pwn(170) : error 017undefined symbol "params"
D:\myownscript\gamemodes\fgrp.pwn(173) : error 017undefined symbol "params"
D:\myownscript\gamemodes\fgrp.pwn(178) : warning 217loose indentation
Pawn compiler 3.2.3664              Copyright 
(c1997-2006ITB CompuPhase
3 Errors

Someone please help me.
Reply
#2

Change params to cmdtext
Reply
#3

This should work:

PHP код:
public OnPlayerCommandText(playeridcmdtext[]) 

    if(
strcmp("/pm"cmdtexttrue10) == 0
    { 
        new 
str[128],id,text[50],pname[MAX_PLAYER_NAME]; 
        if(
sscanf(params"us[50]"idtext)) SendClientMessage(playerid0xFF0000FF"Usage: /pm <id> <message>"); 
        else if(
id == INVALID_PLAYER_IDSendClientMessage(playerid0xFF0000FF"ERROR: Player not connected"); 
        if(
playerid == idSendClientMessage(playerid0xFF0000FF"ERROR: You cannot pm yourself!"); 
        else 
        { 
            
GetPlayerName(idpnamesizeof(pname)); 
            
format(strsizeof(str), "PM To %s(ID %d): %s"pnameidtext); 
            
SendClientMessage(playerid0xFF0000FFstr); 
            
GetPlayerName(playeridpnamesizeof(pname)); 
            
format(strsizeof(str), "PM From %s(ID %d): %s"pnameplayeridtext); 
            
SendClientMessage(id0xFF0000FFstr); 
        } 
        return 
1
    } 
    return 
0

Reply
#4

Quote:
Originally Posted by oMa37
Посмотреть сообщение
This should work:

PHP код:
public OnPlayerCommandText(playeridcmdtext[]) 

    if(
strcmp("/pm"cmdtexttrue10) == 0
    { 
        new 
str[128],id,text[50],pname[MAX_PLAYER_NAME]; 
        if(
sscanf(params"us[50]"idtext)) SendClientMessage(playerid0xFF0000FF"Usage: /pm <id> <message>"); 
        else if(
id == INVALID_PLAYER_IDSendClientMessage(playerid0xFF0000FF"ERROR: Player not connected"); 
        if(
playerid == idSendClientMessage(playerid0xFF0000FF"ERROR: You cannot pm yourself!"); 
        else 
        { 
            
GetPlayerName(idpnamesizeof(pname)); 
            
format(strsizeof(str), "PM To %s(ID %d): %s"pnameidtext); 
            
SendClientMessage(playerid0xFF0000FFstr); 
            
GetPlayerName(playeridpnamesizeof(pname)); 
            
format(strsizeof(str), "PM From %s(ID %d): %s"pnameplayeridtext); 
            
SendClientMessage(id0xFF0000FFstr); 
        } 
        return 
1
    } 
    return 
0

PHP код:
D:\myownscript\gamemodes\fgrp.pwn(164) : error 017undefined symbol "params"
Pawn compiler 3.2.3664              Copyright (c1997-2006ITB CompuPhase
1 Error

I'm getting this error.
Reply
#5

There is no params in OnPlayerCommandText.

Either use zcmd, which is the best option, or use cmdtext[3].
The number 3 changes depending on the length of the command name.
Reply
#6

you can't use sscanf under OnPlayerCommandText because it used to be with CMD: / zcmd commands,

cmdtext isn't empty cmdtext has the full command you wrote not just the thing you write after the command,

your cmdtext now /pm params so this should do the job

also you have to do strfind not strcmp at this case.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
areawhere = -1;
    for(new 
0strlen(cmdtext); i++) {
       switch(
cmdtext[i]) {
          case 
' ': {
             
areawhere i;
             break;
          }
       }
    }
    if(
areawhere == -1areawhere strlen(cmdtext)+1;
    if(
strfind(cmdtext,"/pm"true0) == 0/*strcmp("/pm", cmdtext, true, 10) == 0*/)
    {
        new 
str[128],id,text[50],pname[MAX_PLAYER_NAME];
        if(
sscanf(cmdtext[areawhere], "us[50]"idtext)) return SendClientMessage(playerid0xFF0000FF"Usage: /pm <id> <message>");
        if(
id == INVALID_PLAYER_ID) return SendClientMessage(playerid0xFF0000FF"ERROR: Player not connected");
        if(
playerid == id) return SendClientMessage(playerid0xFF0000FF"ERROR: You cannot pm yourself!");
        
GetPlayerName(idpnamesizeof(pname));
        
format(strsizeof(str), "PM To %s(ID %d): %s"pnameidtext);
        
SendClientMessage(playerid0xFF0000FFstr);
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(strsizeof(str), "PM From %s(ID %d): %s"pnameplayeridtext);
        
SendClientMessage(id0xFF0000FFstr);
        return 
1;
    }
    return 
0;

Reply
#7

Quote:
Originally Posted by jlalt
Посмотреть сообщение
you can't use sscanf under OnPlayerCommandText because it used to be with CMD: / zcmd commands,

cmdtext isn't empty cmdtext has the full command you wrote not just the thing you write after the command,

your cmdtext now /pm params so this should do the job

also you have to do strfind not strcmp at this case.

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
areawhere = -1;
    for(new 
0strlen(cmdtext); i++) {
       switch(
cmdtext[i]) {
          case 
' ': {
             
areawhere i;
             break;
          }
       }
    }
    if(
areawhere == -1areawhere strlen(cmdtext)+1;
    if(
strfind(cmdtext,"/pm"true0) != -1/*strcmp("/pm", cmdtext, true, 10) == 0*/)
    {
        new 
str[128],id,text[50],pname[MAX_PLAYER_NAME];
        if(
sscanf(cmdtext[areawhere], "us[50]"idtext)) return SendClientMessage(playerid0xFF0000FF"Usage: /pm <id> <message>");
        if(
id == INVALID_PLAYER_ID) return SendClientMessage(playerid0xFF0000FF"ERROR: Player not connected");
        if(
playerid == id) return SendClientMessage(playerid0xFF0000FF"ERROR: You cannot pm yourself!");
        
GetPlayerName(idpnamesizeof(pname));
        
format(strsizeof(str), "PM To %s(ID %d): %s"pnameidtext);
        
SendClientMessage(playerid0xFF0000FFstr);
        
GetPlayerName(playeridpnamesizeof(pname));
        
format(strsizeof(str), "PM From %s(ID %d): %s"pnameplayeridtext);
        
SendClientMessage(id0xFF0000FFstr);
        return 
1;
    }
    return 
0;

Only observation in strfind function:

!= -1 - blablabla/pm 0 test
== 0 - /pm 0 test
Reply
#8

Quote:
Originally Posted by F1N4L
Посмотреть сообщение
Only observation in strfind function:

!= -1 - blablabla/pm 0 test
== 0 - /pm 0 test
Thanks for the observation, fixed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)