disable /go command if im in dm/race map
#1

How do I disable /go command if im in a race or deathmatch?

Example: Im gone to /mini and I do /go [playerid] << how do i disabled this. So i am not just teleporting to someone and just leaving deathmatch like a cat.

pawn Код:
CMD:go(playerid, params[])
{
    new ID;//creates a new something idk what we call it :P but it is defined later on or used in something this 1 is used in next line
    if(sscanf(params, "u", ID)) return SendClientMessage(playerid, 0xFFFFFFFF, "{FFFF00}Usage: /go [PlayerID/PartofName]");//checks if you have written something after /goto if no it sends error
    if(!IsPlayerConnected(ID) || ID == playerid) return SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}This player is Offline or it is Yourself");
    if(GetPVarInt(playerid, "GotoEnabled") == 0) return GameTextForPlayer(playerid,"~r~Goes is Disabled",2000,3);
    if(pInEvent[ID] == 1) return GameTextForPlayer(playerid,"Player is in DM/Race",2000,3);
    if(GetPVarInt(playerid, "Jailed") == 1) return GameTextForPlayer(playerid,"Player is Jailed",2000,3);
    new Float:x, Float:y, Float:z, name[MAX_PLAYER_NAME], str[64], i, vw; //creates new variables to store floats, strings and values
    GetPlayerPos(ID, x, y, z);//gets the player id(which we have entered after /goto position and like saves them into x,y,z defined above as floats
    i = GetPlayerInterior(ID);
    vw = GetPlayerVirtualWorld(ID);
    if(i) SetPlayerInterior(playerid, i);
    if(vw) SetPlayerVirtualWorld(playerid, vw);
    if(IsPlayerInAnyVehicle(playerid))
    {
        if(i)
        {
            LinkVehicleToInterior(GetPlayerVehicleID(playerid), i);
            DestroyVehicle(GetPlayerVehicleID(playerid));
        }
        if(vw) SetVehicleVirtualWorld(GetPlayerVehicleID(playerid), vw);
        SetVehiclePos(GetPlayerVehicleID(playerid), x + 1, y + 1, z);
    }
    else SetPlayerPos(playerid, x + 1, y + 1, z);
    GetPlayerName(playerid, name, MAX_PLAYER_NAME);
    format(str, sizeof(str), "{FFFF00}(/go) %s (%d) has teleported to you", name, playerid);
    SendClientMessage(ID, 0xFFFFFFFF, str);
    return 1;
}
Reply
#2

Create a variable
pawn Код:
new IsPlayerInDM[MAX_PLAYERS];
Then add the following
pawn Код:
if(IsPlayerInDM[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF,"/exit before you use this command");
now /exit command
pawn Код:
CMD:exit(playerid, params[])
{
IsPlayerInDM[playerid] = 0;
SpawnPlayer(playerid);
return 1;
}
and under your DM command add

IsPlayerInDM[playerid] = 1;

+REP if it helped.
Reply
#3

Quote:
Originally Posted by Jarnu
Посмотреть сообщение
Create a variable
pawn Код:
new IsPlayerInDM[MAX_PLAYERS];
Then add the following
pawn Код:
if(IsPlayerInDM[playerid] == 1) return SendClientMessage(playerid, 0xFF0000FF,"/exit before you use this command");
now /exit command
pawn Код:
CMD:exit(playerid, params[])
{
IsPlayerInDM[playerid] = 0;
SpawnPlayer(playerid);
return 1;
}
and under your DM command add

IsPlayerInDM[playerid] = 1;

+REP if it helped.
Jarnu thanks for the reply..
If its possible no prompt will show, i only want to disable that command.


EDIT: GOT IT now. thanks bro!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)