Commands help ! (/get , /jail & /unjail)
#1

Hi everybody !
I need 3 cmds ...

I have this for /get :
pawn Код:
if( !strcmp( "/get", cmdtext, true, 4 ) )
    {
        if( !IsPlayerAdmin( playerid ) )
            return 0;
        new Index;
        tmp = strtok( cmdtext, Index );
        new giveplayerid = strval( tmp );
        if( !IsPlayerConnected( giveplayerid ) )
           return SendClientMessage( playerid, 0xAAAAAA, "Player not connected" );
        if( !strlen( tmp ) )
            return SendClientMessage( playerid, 0xAAAAAA, "USAGE: /get [ID]");
        new Float:x, Float:y, Float:z;
        GetPlayerPos( playerid, x, y, z );
        SetPlayerPos( giveplayerid, x, y, z );
        new string[ 128 ];
        new pName[ 24 ], aName[ 24 ];
        GetPlayerName( playerid, aName, 24 );
        GetPlayerName( giveplayerid, pName, 24 );
        format( string, sizeof string, "You have teleported %s to your location", pName );
        SendClientMessage( playerid, 0xAAAAAA, string );
        format( string, sizeof string, "You have been teleported to administrator %s's position", aName );
        return SendClientMessage( giveplayerid, 0xAAAAAA, string );
    }
But if i type: /get , /get 1, /get 2 ...
It always says:

You have teleproted Michael@Belgium to your location
You have been teleported to administrator Michael@Belgium's positions


And for the /(un)jail ... I DON'T FIND IT (in strcmp format !!)

PLZ HELP ;p
Reply
#2

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[256];
  new idx;
  cmd = strtok(cmdtext, idx);//This is the first thing to do
 //Don't use strcmp(cmdtext) with strtok

    if(strcmp(cmd, "/goto", true) == 0)
    {
      if(!IsPlayerAdmin(playerid)) return 0;
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /goto [playerid].");  //Edit my english
      new playerid2;
      playerid2 = strval(tmp);
      new string[MAX_STRING];
      new name[MAX_PLAYER_NAME];
      new name2[MAX_PLAYER_NAME];
      new Float:x, Float:y, Float:z;
      GetPlayerName(playerid,name,sizeof(name));
      GetPlayerName(playerid2,name2,sizeof(name2));
      format(string,sizeof(string),"Admin %s(%d) teleported to your location.",name,playerid);  //Edit my english
      SendClientMessage(playerid2,COLOR_RED,string);
      format(string,sizeof(string), "You went to %s(%d)'s location.",name2,playerid2);  //Edit my english
      SendClientMessage(playerid,COLOR_RED,string);
      GetPlayerPos(playerid2,x,y,z);
      SetPlayerPos(playerid,x+1,y+1,z);
      return 1;
    }
if(strcmp(cmd, "/get", true) == 0)
    {
      if(!IsPlayerAdmin(playerid)) return 0;
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /get [playerid].");  //Edit my english
      new playerid2;
      playerid2 = strval(tmp);
      new string[MAX_STRING];
      new name[MAX_PLAYER_NAME];
      new name2[MAX_PLAYER_NAME];
      new Float:x, Float:y, Float:z;
      GetPlayerName(playerid,name,sizeof(name));
      GetPlayerName(playerid2,name2,sizeof(name2));
      format(string,sizeof(string),"Admin %s(%d) teleported you to him.",name,playerid);  //Edit my english
      SendClientMessage(playerid2,COLOR_RED,string);
      format(string,sizeof(string), "You teleported %s(%d) to you.",name2,playerid2);  //Edit my english
      SendClientMessage(playerid,COLOR_RED,string);
      GetPlayerPos(playerid,x,y,z);
      SetPlayerPos(playerid2,x+1,y+1,z);
      return 1;
    }
   //Also add !IsPlayerConnected etc
    return 0;
}
Reply
#3

Quote:
Originally Posted by [GF]Sasino97
Посмотреть сообщение
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
  new cmd[256];
  new idx;
  cmd = strtok(cmdtext, idx);//This is the first thing to do
 //Don't use strcmp(cmdtext) with strtok

    if(strcmp(cmd, "/goto", true) == 0)
    {
      if(!IsPlayerAdmin(playerid)) return 0;
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /goto [playerid].");  //Edit my english
      new playerid2;
      playerid2 = strval(tmp);
      new string[MAX_STRING];
      new name[MAX_PLAYER_NAME];
      new name2[MAX_PLAYER_NAME];
      new Float:x, Float:y, Float:z;
      GetPlayerName(playerid,name,sizeof(name));
      GetPlayerName(playerid2,name2,sizeof(name2));
      format(string,sizeof(string),"Admin %s(%d) teleported to your location.",name,playerid);  //Edit my english
      SendClientMessage(playerid2,COLOR_RED,string);
      format(string,sizeof(string), "You went to %s(%d)'s location.",name2,playerid2);  //Edit my english
      SendClientMessage(playerid,COLOR_RED,string);
      GetPlayerPos(playerid2,x,y,z);
      SetPlayerPos(playerid,x+1,y+1,z);
      return 1;
    }
if(strcmp(cmd, "/get", true) == 0)
    {
      if(!IsPlayerAdmin(playerid)) return 0;
      tmp = strtok(cmdtext, idx);
      if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_YELLOW, "USAGE: /get [playerid].");  //Edit my english
      new playerid2;
      playerid2 = strval(tmp);
      new string[MAX_STRING];//line error
      new name[MAX_PLAYER_NAME];
      new name2[MAX_PLAYER_NAME];
      new Float:x, Float:y, Float:z;
      GetPlayerName(playerid,name,sizeof(name));
      GetPlayerName(playerid2,name2,sizeof(name2));
      format(string,sizeof(string),"Admin %s(%d) teleported you to him.",name,playerid);  //Edit my english
      SendClientMessage(playerid2,COLOR_RED,string);
      format(string,sizeof(string), "You teleported %s(%d) to you.",name2,playerid2);  //Edit my english
      SendClientMessage(playerid,COLOR_RED,string);
      GetPlayerPos(playerid,x,y,z);
      SetPlayerPos(playerid2,x+1,y+1,z);
      return 1;
    }
   //Also add !IsPlayerConnected etc
    return 0;
}
THANKS
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)