CMDMessage to the admins & some other issue's
#6

Quote:
Originally Posted by Stereotype
Посмотреть сообщение
pawn Код:
forward SendAdminMessage(color,const string[],level); // We are forwarded it

// This down is to send message to admins when someone do something
format(string, 256, "[ADMIN] %s is now spectating %s",spectator , spectating);
SendAdminMessage(-1,string,1);

// We need to make public command now
public SendAdminMessage(color,const string[],level)
{
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if (PlayerInfo[i][pAdmin] >= level)
            {
                SendClientMessage(i, color, string);
                printf("%s", string);
            }
        }
    }
    return 1;
}
Why you made a public function for that ? It can be made with a stock easily
pawn Код:
stock CMDMessageToAdmins(color,Message[])
{
    for(new i; i<MAX_PLAYERS; i++) if(IsPlayerConnected(i) && PlayerInfo[i][AdminLevel] >= 1) SendClientMessage(i, color, Message);
    return 1;
}
Replace your function with this one

And If you don't have a function to get the vehicle name here it is
pawn Код:
stock GetVehicleName(vehiclemodel)
{
    new const VehicleNames[][] =
    {
       "Landstalker", "Bravura", "Buffalo", "Linerunner", "Pereniel", "Sentinel", "Dumper", "Firetruck", "Trashmaster", "Stretch", "Manana", "Infernus","Voodoo", "Pony", "Mule", "Cheetah", "Ambulance", "Leviathan", "Moonbeam", "Esperanto", "Taxi", "Washington", "Bobcat", "Mr Whoopee", "BF Injection", "Hunter", "Premier", "Enforcer",
       "Securicar", "Banshee", "Predator", "Bus", "Rhino", "Barracks", "Hotknife", "Trailer", "Previon", "Coach", "Cabbie", "Stallion", "Rumpo", "RC Bandit", "Romero", "Packer", "Monster", "Admiral", "Squalo", "Seasparrow", "Pizzaboy", "Tram", "Trailer 2", "Turismo", "Speeder", "Reefer", "Tropic", "Flatbed", "Yankee", "Caddy",
       "Solair", "Berkley's RC Van", "Skimmer", "PCJ-600", "Faggio", "Freeway", "RC Baron", "RC Raider", "Glendale", "Oceanic", "Sanchez", "Sparrow", "Patriot", "Quad", "Coastguard", "Dinghy", "Hermes", "Sabre", "Rustler", "ZR3 50", "Walton", "Regina", "Comet", "BMX", "Burrito", "Camper", "Marquis", "Baggage", "Dozer", "Maverick",
       "News Chopper", "Rancher", "FBI Rancher", "Virgo", "Greenwood", "Jetmax", "Hotring", "Sandking", "Blista Compact", "Police Maverick", "Boxville", "Benson", "Mesa", "RC Goblin", "Hotring Racer A", "Hotring Racer B", "Bloodring Banger", "Rancher", "Super GT", "Elegant", "Journey", "Bike", "Mountain Bike", "Beagle", "Cropdust",
       "Stunt", "Tanker", "RoadTrain", "Nebula", "Majestic", "Buccaneer", "Shamal", "Hydra", "FCR-900", "NRG-500", "HPV1000", "Cement Truck", "Tow Truck", "Fortune", "Cadrona", "FBI Truck", "Willard", "Forklift", "Tractor", "Combine", "Feltzer", "Remington", "Slamvan", "Blade", "Freight", "Streak", "Vortex", "Vincent", "Bullet",
       "Clover", "Sadler", "Firetruck", "Hustler", "Intruder", "Primo", "Cargobob", "Tampa", "Sunrise", "Merit", "Utility", "Nevada", "Yosemite", "Windsor", "Monster A", "Monster B", "Uranus", "Jester", "Sultan", "Stratum", "Elegy", "Raindance", "RC Tiger", "Flash", "Tahoma", "Savanna", "Bandito", "Freight", "Trailer", "Kart", "Mower",
       "Duneride", "Sweeper", "Broadway", "Tornado", "AT-400", "DFT-30", "Huntley", "Stafford", "BF-400", "Newsvan", "Tug", "Trailer A", "Emperor", "Wayfarer", "Euros", "Hotdog", "Club", "Trailer B", "Trailer C", "Andromada", "Dodo", "RC Cam", "Launch", "Police Car (LSPD)", "Police Car (SFPD)", "Police Car (LVPD)", "Police Ranger",
       "Picador", "S.W.A.T. Van", "Alpha", "Phoenix", "Glendale", "Sadler", "Luggage Trailer A", "Luggage Trailer B", "Stair Trailer", "Boxville", "Farm Plow", "Utility Trailer"
    };
    new VName[30]; format(VName, sizeof(VName), "%s", VehicleNames[vehiclemodel-400]);
    return _:VName;
}
And your code..
pawn Код:
if(strcmp(cmd, "/veh", true) == 0)
    {
        if(!(PlayerInfo[playerid][pAdmin] >= 4))
            return SendClientMessage(playerid, COLOR_GRAD1, "You are not authorized to use this command.");

        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
            return SendClientMessage(playerid, COLOR_GRAD2, "USAGE: /veh [vehicle name/ID] [color1(optional)] [color2(optional)] [respawnable(optional)]");

        new car = ReturnVehicleModelID(tmp);
        if(!car)
            return SendClientMessage(playerid, COLOR_GREY, "   Invalid vehicle model name/ID.");

        new color1, color2;
        tmp = strtok(cmdtext, idx);
        if(!strlen(tmp))
        {
            color1 = -1;
            color2 = -1;
        }
        else
        {
            color1 = strval(tmp);
            if(color1 < -1 || color1 > 200)
                return SendClientMessage(playerid, COLOR_GREY, "   Enter a valid color [0-200]");

            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp)) color2 = color1;
            else color2 = strval(tmp);
            if(color2 < -1 || color2 > 200)
                return SendClientMessage(playerid, COLOR_GREY, "   Enter a valid color [0-200]");
        }

        if(IsPlayerInAnyVehicle(playerid))
            RemovePlayerFromVehicle(playerid);
        new Float:X, Float:Y, Float:Z, Float:A;
        GetPlayerPos(playerid, X,Y,Z);
        GetPlayerFacingAngle(playerid,A);
        new carid = CreateVehicle(car, X,Y,Z,A, color1, color2, -1);
       
        new playeridname[MAX_PLAYER_NAME]; GetPlayerName(playerid, playeridname, MAX_PLAYER_NAME);
        new string[128]; format(string, sizeof string, "ADMIN: %s has spawned a %s", playeridname, GetVehicleName(GetVehicleModel(carid)));
        CMDMessageToAdmins(COLOR_ADMINCOMMAND, string);
       
        tmp = strtok(cmdtext, idx);
        if(strval(tmp) != 1)
        {
            gDestroyVehicle[carid] = 1;
        }
        gCarLock[carid] = 0;
        PutPlayerInVehicle(playerid,carid,0);
        LinkVehicleToInterior(carid,GetPlayerInterior(playerid));
        for(new i = 0; i < sizeof(CreatedCars); i++)
        {
            if(CreatedCars[i] == INVALID_VEHICLE_ID)
            {
                CreatedCars[i] = carid;
                break;
            }
        }
        return 1;
    }
   
    if(strcmp(cmd, "/spec", true) == 0 || strcmp(cmd, "/recon", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            if(PlayerInfo[playerid][pAdmin] < 1)
            {
                SendClientMessage(playerid, COLOR_GREY, "   You are not authorized to use that command !");
                return 1;
            }
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_LIGHTRED, "USAGE: /spec [playerid/off]");
                return 1;
            }

            giveplayerid = ReturnUser(tmp);
            if(IsPlayerNPC(giveplayerid)) return 1;
            if(strcmp("off", tmp, true, strlen(tmp)) == 0)
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    SendClientMessage(playerid, COLOR_LIGHTRED, "   You are not spectating anyone !");
                    return 1;
                }

                SetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                SetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                SetPlayerVirtualWorld(playerid, PlayerInfo[playerid][pVirtualWorld]);
                SetPlayerInterior(playerid, PlayerInfo[playerid][pInt]);
                SetPlayerPos(playerid, PlayerInfo[playerid][pSPos_x], PlayerInfo[playerid][pSPos_y], PlayerInfo[playerid][pSPos_z]);
                SetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                SendClientMessage(playerid, COLOR_LIGHTRED, "You are no longer spectating.");
                TogglePlayerSpectating(playerid, 0);
                SpectatedID[playerid] = INVALID_PLAYER_ID;
                SpectateType[playerid] = ADMIN_SPEC_TYPE_NONE;
                HidePM[playerid] = 0;
                PhoneOnline[playerid] = 0;
                ResetPlayerAdminWeaponsEx(playerid);
                return 1;
            }
            if(IsPlayerConnected(giveplayerid))
            {
                if(GetPlayerState(playerid) != PLAYER_STATE_SPECTATING)
                {
                    PlayerInfo[playerid][pInt] = GetPlayerInterior(playerid);
                    GetPlayerHealth(playerid, PlayerInfo[playerid][pHealth]);
                    GetPlayerArmour(playerid, PlayerInfo[playerid][pArmor]);
                    GetPlayerPos(playerid, PlayerInfo[playerid][pSPos_x], PlayerInfo[playerid][pSPos_y], PlayerInfo[playerid][pSPos_z]);
                    GetPlayerFacingAngle(playerid, PlayerInfo[playerid][pSPos_r]);
                }
                SetPlayerVirtualWorld(playerid, GetPlayerVirtualWorld(giveplayerid));
                SetPlayerInterior(playerid, GetPlayerInterior(giveplayerid));
                TogglePlayerSpectating(playerid, 1);
                SpectatedID[playerid] = giveplayerid;
                HidePM[playerid] = 1;
                PhoneOnline[playerid] = 1;
                if(IsPlayerInAnyVehicle(giveplayerid))
                {
                    PlayerSpectateVehicle(playerid, GetPlayerVehicleID(giveplayerid));
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_VEHICLE;
                }
                else
                {
                    PlayerSpectatePlayer(playerid, giveplayerid);
                    SpectateType[playerid] = ADMIN_SPEC_TYPE_PLAYER;
                }
               
                new playeridname[MAX_PLAYER_NAME]; GetPlayerName(playerid, playeridname, MAX_PLAYER_NAME);
                new giveplayeridname[MAX_PLAYER_NAME]; GetPlayerName(playerid, giveplayeridname, MAX_PLAYER_NAME);
                new string[128]; format(string, sizeof string, "ADMIN: %s is now spectating %s", playeridname, giveplayeridname);
                CMDMessageToAdmins(COLOR_ADMINCOMMAND, string);
            }
            else return SendClientMessage(playerid, COLOR_GREY, "   That player isn't active !");
        }
        return 1;
    }
Quote:
Originally Posted by Screaming
Посмотреть сообщение
How to add a textdraw or something? A little text above a player's name... like "Administrator".
Make a 3DTextLabel And attach it to the player
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)