error with a command/hi
#1

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"
Reply
#2

ι suggest you to use dcmd!
it is more easy to create cmd which contains [id]
Reply
#3

And how to create?
Reply
#4

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

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)