SA-MP Forums Archive
Help with /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: Help with /hi (/showthread.php?tid=121428)



Help with /hi - Aram555 - 16.01.2010

The command does not work.

Код:
if (strcmp(cmd, "/hi", true) == 0)
  {
    new tmp[256],id;
    tmp = strtok(cmdtext, idx);
    if (!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "ПРИМИНЕНИЕ: /hi id "); 
    id = strval(tmp);
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "Такой игрок не подключён!");
    new string[255],plname[24],idname[24];
    GetPlayerName(playerid,plname,sizeof(plname));
    GetPlayerName(id,idname,sizeof(idname));
    format(string,sizeof(string),".:: %s приветствует %s",plname,idname);
    SendClientMessageToAll(0x00FF00AA,string);
    return 1;
  }
2 Warnings:
Код:
warning 219: local variable "tmp" shadows a variable at a preceding level
warning 219: local variable "string" shadows a variable at a preceding level
In what the reason?


Re: Help with /hi - GTAguillaume - 16.01.2010

You already maked variables called "string" and "idx".

Код:
if (strcmp(cmd, "/hi", true) == 0)
  {
    new id;
    tmp = strtok(cmdtext, idx);
    if (!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000AA, "ПРИМИНЕНИЕ: /hi id "); 
    id = strval(tmp);
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "Такой игрок не подключён!");
    new plname[24],idname[24];
    GetPlayerName(playerid,plname,sizeof(plname));
    GetPlayerName(id,idname,sizeof(idname));
    format(string,sizeof(string),".:: %s приветствует %s",plname,idname);
    SendClientMessageToAll(0x00FF00AA,string);
    return 1;
  }



Re: Help with /hi - s0nic - 17.01.2010

Quote:
Originally Posted by Aram555
Код:
2 Warnings:
warning 219: local variable "tmp" shadows a variable at a preceding level
warning 219: local variable "string" shadows a variable at a preceding level
In what the reason?
What GTAguillaume should work..the reason is because you most likely have tmp and string already at the top of OnPlayerCommandText..


Re: Help with /hi - Aram555 - 17.01.2010

How still to make the such:
%s (ID: %d) welcome %s (ID: %d)
does not show ID the correct