Problem with OnPlayerCommandText
#1

Hi all!

PHP код:
//---------------------------<[ OnPlayerCommandText ]>--------------------------------------------------------
public OnPlayerCommandText(playeridcmdtext[])
{
    new 
string[256];
    new 
cmd[256];
    new 
idx;
    new 
tmp[256];
    
cmd strtok(cmdtextidx);
//-
    
if(strcmp(cmd"/goto"true) == 0)
    {
        if(
IsPlayerConnected(playerid))
        {
           if(
Info[playerid][pAdmin] >= 1)
           {
              
tmp strtok(cmdtextidx);
              if(!
strlen(tmp))
              {
                  
SendClientMessage(playeridCOLOR_GRAD1"[INFO] {FFFFFF} /goto [ID/PlayerName]");
                  return 
1;
              }
              new 
Float:plocx,Float:plocy,Float:plocz;
              new 
plo;
              
plo ReturnUser(tmp);
              if (
IsPlayerConnected(plo))
              {
                if(
plo != INVALID_PLAYER_ID)
                {
                        
GetPlayerPos(plo,plocx,plocy,plocz);
                        if (
GetPlayerState(playerid) == 2)
                        {
                            new 
tmpcar GetPlayerVehicleID(playerid);
                            
SetVehiclePos(tmpcarplocxplocy+4plocz);
                            
TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
                        }
                        else
                        {
                            
SetPlayerPos(playerid,plocx,plocy+2plocz);
                        }
                        
SetPlayerInterior(playerid,GetPlayerInterior(plo));
                        
SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(plo));
                        
SendClientMessage(playeridCOLOR_LIGHTBLUE"* You are teleported");
                    }
                    else
                    {
                        
SendClientMessage(playeridCOLOR_GRAD1"   You are not autorized!");
                    }
                }
                else
                {
                    
format(stringsizeof(string), "   %d  is not an active player."plo);
                    
SendClientMessage(playeridCOLOR_GRAD1string);
                   }
            }
         }
        return 
1;
     }
    return 
1;
 } 
Recently we added the "OnPlayerCommandText" a gamemode that was not installed.
I added a command and it does not work (I do not give any compile error)
What can I do?
Reply
#2

Try this sir

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new cmd[256];
    new idx;
    new tmp[256];
    cmd = strtok(cmdtext, idx);
//-

    if(strcmp(cmd, "/goto", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(Info[playerid][pAdmin] >= 1)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "[INFO] {FFFFFF} /goto [ID/PlayerName]");
                    return 1;
                }
                new Float:plocx,Float:plocy,Float:plocz;
                new plo;
                plo = ReturnUser(tmp);
                if (IsPlayerConnected(plo))
                {
                    if(plo != INVALID_PLAYER_ID)
                    {
                        GetPlayerPos(plo,plocx,plocy,plocz);
                        if (GetPlayerState(playerid) == 2)
                        {
                            new tmpcar = GetPlayerVehicleID(playerid);
                            SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                            TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
                        }
                        else
                        {
                            SetPlayerPos(playerid,plocx,plocy+2, plocz);
                        }
                        SetPlayerInterior(playerid,GetPlayerInterior(plo));
                        SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(plo));
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You are teleported");
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   You are not autorized!");
                    }
                }
                else
                {
                    format(string, sizeof(string), "   %d  is not an active player.", plo);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
        }
        return 1;
    }
    return 0;
 }
Reply
#3

Quote:
Originally Posted by UploaD
Посмотреть сообщение
Try this sir

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new cmd[256];
    new idx;
    new tmp[256];
    cmd = strtok(cmdtext, idx);
//-

    if(strcmp(cmd, "/goto", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(Info[playerid][pAdmin] >= 1)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "[INFO] {FFFFFF} /goto [ID/PlayerName]");
                    return 1;
                }
                new Float:plocx,Float:plocy,Float:plocz;
                new plo;
                plo = ReturnUser(tmp);
                if (IsPlayerConnected(plo))
                {
                    if(plo != INVALID_PLAYER_ID)
                    {
                        GetPlayerPos(plo,plocx,plocy,plocz);
                        if (GetPlayerState(playerid) == 2)
                        {
                            new tmpcar = GetPlayerVehicleID(playerid);
                            SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                            TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
                        }
                        else
                        {
                            SetPlayerPos(playerid,plocx,plocy+2, plocz);
                        }
                        SetPlayerInterior(playerid,GetPlayerInterior(plo));
                        SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(plo));
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You are teleported");
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   You are not autorized!");
                    }
                }
                else
                {
                    format(string, sizeof(string), "   %d  is not an active player.", plo);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
        }
        return 1;
    }
    return 0;
 }
Doesn't work, i can't acces command.
Reply
#4

Quote:
Originally Posted by Johnny_Ionut
Посмотреть сообщение
Doesn't work, i can't acces command.
It won't if you're using any other command processors like zcmd or ycmd.
Reply
#5

Quote:
Originally Posted by Lordzy
Посмотреть сообщение
It won't if you're using any other command processors like zcmd or ycmd.
You have any ideea how to "enable" ' public onplayercommand ' ?
Reply
#6

Quote:
Originally Posted by ******
Посмотреть сообщение
Remove the command processors. But remember that doing so is a massive downgrade.
Sorry for question ... how can i do it?
Reply
#7

Quote:
Originally Posted by ******
Посмотреть сообщение
Delete the include lines.
Ok, thanks !
Reply
#8

I tried to delete the Includes and still does not work. Anything else I can do?
Reply
#9

Doesn't work means, you are not TPing or it says 'SERVER: Unknown command.'?
Reply
#10

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    new string[256];
    new cmd[256];
    new idx;
    new tmp[256];
    cmd = strtok(cmdtext, idx);
//-

    if(strcmp(cmd, "/goto", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(Info[playerid][pAdmin] >= 1)
            {
                tmp = strtok(cmdtext, idx);
                if(!strlen(tmp))
                {
                    SendClientMessage(playerid, COLOR_GRAD1, "[INFO] {FFFFFF} /goto [ID/PlayerName]");
                    return 1;
                }
                new Float:plocx,Float:plocy,Float:plocz;
                new plo;
                plo = ReturnUser(tmp);
                if (IsPlayerConnected(plo))
                {
                    if(plo != INVALID_PLAYER_ID)
                    {
                        GetPlayerPos(plo,plocx,plocy,plocz);
                        if (GetPlayerState(playerid) == 2)
                        {
                            new tmpcar = GetPlayerVehicleID(playerid);
                            SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                            TelePos[playerid][0] = 0.0;TelePos[playerid][1] = 0.0;
                        }
                        else
                        {
                            SetPlayerPos(playerid,plocx,plocy+2, plocz);
                        }
                        SetPlayerInterior(playerid,GetPlayerInterior(plo));
                        SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(plo));
                        SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You are teleported");
                    }
                    else
                    {
                        SendClientMessage(playerid, COLOR_GRAD1, "   You are not autorized!");
                    }
                }
                else
                {
                    format(string, sizeof(string), "   %d  is not an active player.", plo);
                    SendClientMessage(playerid, COLOR_GRAD1, string);
                }
            }
        }
        return 1;
    }
    return 0;
 }


Most modes of the source from which we have not implemented "public onplayercommandtext"
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)