SA-MP Forums Archive
Enter command as another player - 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)
+--- Thread: Enter command as another player (/showthread.php?tid=421403)



Enter command as another player - Nathan_Taylor - 09.03.2013

Is there any way to enter a command as a different player, this is in my code
pawn Код:
if (PRESSED(KEY_CTRL_BACK))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                new vehicle = GetPlayerVehicleID(playerid);
                SetVehicleHealth(vehicle, 100.00);
                RepairVehicle(vehicle);
            }
            else
            {
                SetPlayerHealth(playerid, 100.00);
                SetPlayerArmour(playerid, 100.00);
            }
        }
    }
However, I would nuch rather it be something like this

pawn Код:
if (PRESSED(KEY_CTRL_BACK))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                EnterCommandFromPlayer(playerid, "/healcar");
            } else {
                new healme[128];
                format(healme, sizeof(healme), "/heal %i", playerid);
                EnterCommandFromPlayer(playerid, healme);
            }
        }
    }
Because those commands already have messages that are being sent out to all players. I could just copy/paste messages into here but then if I need to make any changes ion the fuutre, I will probably forget to edit this one resulting in the wrong messsage being displayed


Re: Enter command as another player - gaLB - 09.03.2013

Insted of
Код:
EnterCommandFromPlayer(playerid, "/healcar");
You can use -
Код:
OnPlayerCommandText(playerid, "/healcar");



Re: Enter command as another player - Nathan_Taylor - 09.03.2013

Quote:
Originally Posted by gaLB
Посмотреть сообщение
Insted of
Код:
EnterCommandFromPlayer(playerid, "/healcar");
You can use -
Код:
OnPlayerCommandText(playerid, "/healcar");
That doesn't work, I have this in my code
pawn Код:
if (PRESSED(KEY_ANALOG_UP))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                /*new vehicle = GetPlayerVehicleID(playerid);
                SetVehicleHealth(vehicle, 100.00);
                RepairVehicle(vehicle);*/

                OnPlayerCommandText(playerid, "/healcar");
                SendClientMessage(playerid, -1, "pressed 8");
            }
            else
            {
                /*SetPlayerHealth(playerid, 100.00);
                SetPlayerArmour(playerid, 100.00);*/

                new healme[128];
                format(healme, sizeof(healme), "/heal %i", playerid);
                OnPlayerCommandText(playerid, healme);
                SendClientMessage(playerid, -1, "pressed 8");
            }
        }
    }
When I press the button, I get the "pressed 8" message (only while in car?) but it doesn't get healed.


Re: Enter command as another player - Nathan_Taylor - 09.03.2013

bumpppp


Re: Enter command as another player - Threshold - 09.03.2013

If you're using zcmd, you can easily do this:
pawn Код:
if (PRESSED(KEY_ANALOG_UP))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                /*new vehicle = GetPlayerVehicleID(playerid);
                SetVehicleHealth(vehicle, 100.00);
                RepairVehicle(vehicle);*/

                cmd_healcar(playerid, "");
                SendClientMessage(playerid, -1, "pressed 8");
            }
            else
            {
                /*SetPlayerHealth(playerid, 100.00);
                SetPlayerArmour(playerid, 100.00);*/

                cmd_heal(playerid, playerid);
                SendClientMessage(playerid, -1, "pressed 8");
            }
        }
    }



Re: Enter command as another player - Nathan_Taylor - 09.03.2013

pawn Код:
if (PRESSED(KEY_ANALOG_UP))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                cmd_healcar(playerid, "");
                SendClientMessage(playerid, -1, "pressed 8");
            }
            else
            {
                cmd_heal(playerid, playerid);
            }
        }
    }
gives me the following errors
Код:
nateRP.pwn(853) : error 017: undefined symbol "cmd_healcar"
nateRP.pwn(858) : error 017: undefined symbol "cmd_heal"
and I am using zcmd


Respuesta: Re: Enter command as another player - JustBored - 09.03.2013

Quote:
Originally Posted by Nathan_Taylor
Посмотреть сообщение
pawn Код:
if (PRESSED(KEY_ANALOG_UP))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                cmd_healcar(playerid, "");
                SendClientMessage(playerid, -1, "pressed 8");
            }
            else
            {
                cmd_heal(playerid, playerid);
            }
        }
    }
gives me the following errors
Код:
nateRP.pwn(853) : error 017: undefined symbol "cmd_healcar"
nateRP.pwn(858) : error 017: undefined symbol "cmd_heal"
and I am using zcmd
pawn Код:
if (PRESSED(KEY_ANALOG_UP))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                return cmd_healcar(playerid, params);
                SendClientMessage(playerid, -1, "pressed 8");
            }
            else
            {
                return cmd_heal(playerid, params);
            }
        }
    }
Try.


Re: Enter command as another player - Nathan_Taylor - 10.03.2013

pawn Код:
if (PRESSED(KEY_ANALOG_UP))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                return cmd_healcar(playerid, "");
            }
            else
            {
                return cmd_heal(playerid, playerid);
            }
        }
    }
Still get these errors
pawn Код:
nateRP.pwn(853) : error 017: undefined symbol "cmd_healcar"
nateRP.pwn(858) : error 017: undefined symbol "cmd_heal"



Respuesta: Re: Enter command as another player - JustBored - 10.03.2013

Quote:
Originally Posted by Nathan_Taylor
Посмотреть сообщение
pawn Код:
if (PRESSED(KEY_ANALOG_UP))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                return cmd_healcar(playerid, "");
            }
            else
            {
                return cmd_heal(playerid, playerid);
            }
        }
    }
Still get these errors
pawn Код:
nateRP.pwn(853) : error 017: undefined symbol "cmd_healcar"
nateRP.pwn(858) : error 017: undefined symbol "cmd_heal"
pawn Код:
if (PRESSED(KEY_ANALOG_UP))
    {
        if(pInfo[playerid][Admin] > 1){
            if(IsPlayerInAnyVehicle(playerid))
            {
                return cmd_healcar(playerid, params);
                SendClientMessage(playerid, -1, "pressed 8");
            }
            else
            {
                return cmd_heal(playerid, params);
            }
        }
    }



Re: Enter command as another player - Nathan_Taylor - 10.03.2013

How would that solve it? The error is
pawn Код:
nateRP.pwn(853) : error 017: undefined symbol "cmd_healcar"
nateRP.pwn(858) : error 017: undefined symbol "cmd_heal"
Undefined symbol. Meaning that "cmd_healcar" doesn't exist.