Enter command as another player
#1

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

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

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.
Reply
#4

bumpppp
Reply
#5

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");
            }
        }
    }
Reply
#6

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

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.
Reply
#8

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

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);
            }
        }
    }
Reply
#10

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)