error with a command/hi - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: error with a command/hi (
/showthread.php?tid=121695)
error with a command/hi -
Aram555 - 17.01.2010
made/hi id one error gives
command:
Код:
if (strcmp(cmd, "/hi", true) == 0)
{
tmp = strtok(cmdtext, id);
giveplayerid = strval(tmp);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_RED, "ПРИМЕНЕНИЕ: /hi [ID]");
if(!IsPlayerConnected(giveplayerid)) return SendClientMessage(playerid, COLOR_RED, "Ошибка!: не активный ID игрока");
if(playerid == giveplayerid) return SendClientMessage(playerid,COLOR_RED,"Ошибка!: ты не можешь приветствовать себя!");
new plname[24],idname[24];
GetPlayerName(playerid,plname,sizeof(plname));
GetPlayerName(giveplayerid,idname,sizeof(idname));
format(string,sizeof(string),".:: %s[ID: %d] приветствует %s[ID:%d]",plname,playerid,idname,giveplayerid);
SendClientMessageToAll(0x00FF00AA,string);
return 1;
}
1 error:
error 017: undefined symbol "id"
Re: error with a command/hi -
akis_tze - 17.01.2010
ι suggest you to use dcmd!
it is more easy to create cmd which contains [id]
Re: error with a command/hi -
Aram555 - 17.01.2010
And how to create?
Re: error with a command/hi -
Niixie - 17.01.2010
in dcmd theres defined Params and Playerid.. Playerid is the person who is typing the command, and params is what he types afterwards the command.
ex. /hi [id]
pawn Код:
dcmd_hi(playerid, params[])
{
new player;
if (sscanf(params, "d", player)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname]");
else if (player == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
else if (player == playerid) SendClientMessage(playerid, 0xFF0000AA, "You cant /hi yourself");
{
//What should the command do?
}
return 1;
}
UNTESTED!
Re: error with a command/hi -
kmzr - 18.01.2010
If you're going to use dcmd then define it, put this at the top of your script:
Код:
#define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1
try this
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
dcmd(hi, 2, cmdtext);
return 0;
}
dcmd_hi(playerid, params[])
{
new pName[24];
new myString[128];
GetPlayerName(playerid, pName, sizeof(pName));
format(myString, sizeof(myString), " %s [%d]: %s", pName, params);
SendClientMessageToAll(COLOR_RED, myString);
return 1;
}
untested