public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/pm", cmdtext, true, 10) == 0)
{
new str[128],id,pname[MAX_PLAYER_NAME];
if(sscanf(params, "us", id, params)) SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
if(playerid == id) SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!");
else
{
GetPlayerName(id, pname, sizeof(pname));
format(str, sizeof(str), "PM To %s(ID %d): %s", pname, id, params);
SendClientMessage(playerid, 0xFF0000FF, str);
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "PM From %s(ID %d): %s", pname, playerid, params);
SendClientMessage(id, 0xFF0000FF, str);
}
return 1;
}
return 0;
}
D:\myownscript\gamemodes\fgrp.pwn(164) : error 017: undefined symbol "params"
D:\myownscript\gamemodes\fgrp.pwn(170) : error 017: undefined symbol "params"
D:\myownscript\gamemodes\fgrp.pwn(173) : error 017: undefined symbol "params"
D:\myownscript\gamemodes\fgrp.pwn(178) : warning 217: loose indentation
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
3 Errors.
public OnPlayerCommandText(playerid, cmdtext[])
{
if(strcmp("/pm", cmdtext, true, 10) == 0)
{
new str[128],id,text[50],pname[MAX_PLAYER_NAME];
if(sscanf(params, "us[50]", id, text)) SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
else if(id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
if(playerid == id) SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!");
else
{
GetPlayerName(id, pname, sizeof(pname));
format(str, sizeof(str), "PM To %s(ID %d): %s", pname, id, text);
SendClientMessage(playerid, 0xFF0000FF, str);
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "PM From %s(ID %d): %s", pname, playerid, text);
SendClientMessage(id, 0xFF0000FF, str);
}
return 1;
}
return 0;
}
This should work:
PHP код:
|
D:\myownscript\gamemodes\fgrp.pwn(164) : error 017: undefined symbol "params"
Pawn compiler 3.2.3664 Copyright (c) 1997-2006, ITB CompuPhase
1 Error.
public OnPlayerCommandText(playerid, cmdtext[])
{
new areawhere = -1;
for(new i = 0; i < strlen(cmdtext); i++) {
switch(cmdtext[i]) {
case ' ': {
areawhere = i;
break;
}
}
}
if(areawhere == -1) areawhere = strlen(cmdtext)+1;
if(strfind(cmdtext,"/pm", true, 0) == 0/*strcmp("/pm", cmdtext, true, 10) == 0*/)
{
new str[128],id,text[50],pname[MAX_PLAYER_NAME];
if(sscanf(cmdtext[areawhere], "us[50]", id, text)) return SendClientMessage(playerid, 0xFF0000FF, "Usage: /pm <id> <message>");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not connected");
if(playerid == id) return SendClientMessage(playerid, 0xFF0000FF, "ERROR: You cannot pm yourself!");
GetPlayerName(id, pname, sizeof(pname));
format(str, sizeof(str), "PM To %s(ID %d): %s", pname, id, text);
SendClientMessage(playerid, 0xFF0000FF, str);
GetPlayerName(playerid, pname, sizeof(pname));
format(str, sizeof(str), "PM From %s(ID %d): %s", pname, playerid, text);
SendClientMessage(id, 0xFF0000FF, str);
return 1;
}
return 0;
}
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 код:
|
Only observation in strfind function:
!= -1 - blablabla/pm 0 test == 0 - /pm 0 test |