I need help with a command
#1

I was just editing a /gethere command I made when I (for some reason) realized I cannot think of a way to check if the targetid's admin level is higher than the playerid's admin level when using this command, so that the lower leveled admins cannot teleport higher leveled admins to them.

Код:
CMD:gethere(playerid, params[])
{
	if(PlayerInfo[playerid][pAdmin] >= 2)
	{
		new targetid, naot[128], sendername[MAX_PLAYER_NAME];
 		if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, -1, "/gethere [playerid/partofname]");
  		new Float:Tpos[3];
   		if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, -1, "That player is not online!");
		GetPlayerPos(playerid, Tpos[0], Tpos[1], Tpos[2]);
		SetPlayerPos(targetid, Tpos[0], Tpos[1], Tpos[2]);
		GetPlayerName(playerid, sendername, sizeof(sendername));
		format(naot, sizeof(naot), "You have been teleported by admin %s!", sendername);
		SendClientMessage(targetid, -1, naot);
		GetPlayerName(targetid, sendername, sizeof(sendername));
		format(naot, sizeof(naot), "You have teleported %s to you.", sendername);
		SendClientMessage(playerid, -1, naot);

	}
	return 1;
}
That's the code I've come up with. Basically I was asking if anyone could give me an example (Doesn't necessarily have to be my code, just an example so I can learn).
Reply
#2

pawn Код:
CMD:gethere(playerid, params[])
{
    new giveplayerid;
    if(sscanf(params, "u", giveplayerid)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /gethere [playerid]");

    new Float:plocx,Float:plocy,Float:plocz;
    if (IsPlayerConnected(giveplayerid))
    {
        if(PlayerInfo[giveplayerid][pAdmin] >= PlayerInfo[playerid][pAdmin])
        {
            SendClientMessageEx(playerid, COLOR_WHITE, "You can't perform this action on an equal or higher level administrator.");
            return 1;
        }
        if (PlayerInfo[playerid][pAdmin] >= 2)
        {
            if(GetPlayerState(giveplayerid) == PLAYER_STATE_SPECTATING)
            {
                SendClientMessageEx(playerid, COLOR_GRAD2, "That player is spectating someone.");
                return 1;
            }
            GetPlayerPos(playerid, plocx, plocy, plocz);
            Streamer_UpdateEx(giveplayerid, plocx, plocy, plocz);
            SetPVarInt(playerid, "BeingTeleported", 1);
            SetPlayerVirtualWorld(giveplayerid, PlayerInfo[playerid][pVW]);

            PlayerInfo[giveplayerid][pLocal] = PlayerInfo[playerid][pLocal];

            if (GetPlayerState(giveplayerid) == 2)
            {
                TelePos[giveplayerid][0] = 0.0;
                TelePos[giveplayerid][1] = 0.0;
                new tmpcar = GetPlayerVehicleID(giveplayerid);
                SetVehiclePos(tmpcar, plocx, plocy+4, plocz);
                LinkVehicleToInterior(GetPlayerVehicleID(giveplayerid), GetPlayerInterior(playerid));
                SetPlayerInterior(giveplayerid, GetPlayerInterior(playerid));
                SetVehicleVirtualWorld(GetPlayerVehicleID(giveplayerid), GetPlayerVirtualWorld(playerid));
                SetPlayerVirtualWorld(giveplayerid, GetPlayerVirtualWorld(playerid));
            }
            else
            {
                SetPlayerPos(giveplayerid,plocx,plocy+2, plocz);
                SetPlayerInterior(giveplayerid, GetPlayerInterior(playerid));
                SetPlayerVirtualWorld(giveplayerid, GetPlayerVirtualWorld(playerid));
            }

            SendClientMessageEx(giveplayerid, COLOR_GRAD1, "   You have been teleported!");
        }
        else
        {
            SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command!");
        }

    }
    else SendClientMessageEx(playerid, COLOR_GRAD1, "Invalid player specified.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)