Help with /spec command
#1

Hi, i need help with /spec command. I added but is rcon admin, i want to change acces only if player have pAdmin >= 1 (Admin Level 1), i think this is code for this: if(PlayerInfo[playerid][pAdmin] >= 1).
Who can change the script from below to the same script but with restriction minimum Admin Level 1 and if isn't admin to say you are not authorizated to use this command. This is the script:
Код:
#include <a_samp>
#include <zcmd>
#include <sscanf> // Since you might have the newer version of sscanf it would be '#include <sscanf2>'
#include <A_samp>
#include <samc>
#include <Core>
#include <Float>
#include <Time>
#include <File>
#include <Utils>
#include <Morphinc>
#include <Streamer>
#include <progress>
#include <audio>
#include <foreach>
static gTeam[MAX_PLAYERS];

#undef MAX_PLAYERS
#define MAX_PLAYERS 50  // Here you need to set the maximum number of players able to play on your server at any given time, I'll put 32 because that's the max players on my server.
#define Grey 0xC0C0C0FF // Defining the color 'Grey'

enum pInfo
{
	pKey[128],
	pLevel,
	pVipRank,
	pPin,
	pAdmin,
	pHelper,
	pExamen,
	pExamen2,
	pExamen3,
	pDisabled,
	pFightStyle,
	pDonateRank,
	gPupgrade,
	pConnectTime,
	pReg,
	pSex,
	pAge,
	pOrigin,
	pCK,
	pMuted,
	pMuteTime,
	pExp,
	pCash,
	pAccount,
	pCrimes,
	pKills,
	pDeaths,
	pArrested,
	pWantedDeaths,
	pPhoneBook,
	pLottoNr,
	pFishes,
	pBiggestFish,
	pJob,
	pPayCheck,
	pHeadValue,
	pJailed,
	pJailTime,
	pMats,
	pDrugs,
	pLeader,
	pMember,
	pFMember,
	pRank,
	pChar,
	pContractTime,
	pDetSkill,
	pSexSkill,
	pBoxSkill,
	pLawSkill,
	pMechSkill,
	pJackSkill,
	pCarSkill,
	pNewsSkill,
	pDrugsSkill,
	pCookSkill,
	pFishSkill,
	Float:pHealth,
	Float:pSHealth,
	pInt,
	pLocal,
	pTeam,
	pModel,
	pPnumber,
	pPhousekey,
	pPcarkey,
	pPcarkey2,
	pPcarkey3,
	pPelikey,
	pPelikey2,
	pPelikey3,
	pPboatkey,
	pPboatkey2,
	pPboatkey3,
	pPbiskey,
	Float:pPos_x,
	Float:pPos_y,
	Float:pPos_z,
	pCarLic,
	pFlyLic,
	pBoatLic,
	pFishLic,
	pGunLic,
	pPassPort,
	pGun1,
	pGun2,
	pGun3,
	pGun4,
	pAmmo1,
	pAmmo2,
	pAmmo3,
	pAmmo4,
	pCarTime,
	pPayDay,
	pAWarns,
	pPayDayHad,
	pCDPlayer,
	pWins,
	pLoses,
	pAlcoholPerk,
	pDrugPerk,
	pMiserPerk,
	pPainPerk,
	pTraderPerk,
	pTut,
	pMissionNr,
	pWarns,
	pFwarn,
	pAdjustable,
	pFuel,
	pWantedLevel,
	pFS,
	pClock,
	pSmoke,
	pColor,
	pPaintJob,
	pSpray,
	pInregistrare,
	pBeer,
	pRdeath,
	pBilet,
	pAbonament,
	pLLogin,
	pSpawntaxi,
	pFrozen,
	pTowc,
	pMaskuse,
	pMask,
	pMarried,
	pMarriedTo[128],
};
new PlayerInfo[MAX_PLAYERS][pInfo];
new String[128], Float:SpecX[MAX_PLAYERS], Float:SpecY[MAX_PLAYERS], Float:SpecZ[MAX_PLAYERS], vWorld[MAX_PLAYERS], Inter[MAX_PLAYERS];
new IsSpecing[MAX_PLAYERS], Name[MAX_PLAYER_NAME], IsBeingSpeced[MAX_PLAYERS],spectatorid[MAX_PLAYERS];

COMMAND:spec(playerid, params[])
{
    new id;// This will hold the ID of the player you are going to be spectating.
    if(!IsPlayerAdmin(playerid))return 0;// This checks if the player is logged into RCON, if not it will return 0; (Showing "SERVER: Unknown Command") You can replace it with your own admin check.
    if(sscanf(params,"u", id))return SendClientMessage(playerid, Grey, "Usage: /spec [id]");// Now this is where we use sscanf to check if the params were filled, if not we'll ask you to fill them
    if(id == playerid)return SendClientMessage(playerid,Grey,"You cannot spec yourself.");// Just making sure.
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, Grey, "Player not found!");// This is to ensure that you don't fill the param with an invalid player id.
    if(IsSpecing[playerid] == 1)return SendClientMessage(playerid,Grey,"You are already specing someone.");// This will make you not automatically spec someone else by mistake.
    GetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);// This is getting and saving the player's position in a variable so they'll respawn at the same place they typed '/spec'
    Inter[playerid] = GetPlayerInterior(playerid);// Getting and saving the interior.
    vWorld[playerid] = GetPlayerVirtualWorld(playerid);//Getting and saving the virtual world.
    TogglePlayerSpectating(playerid, true);// Now before we use any of the 3 functions listed above, we need to use this one. It turns the spectating mode on.
    if(IsPlayerInAnyVehicle(id))//Checking if the player is in a vehicle.
    {
     if(GetPlayerInterior(id) > 0)//If the player's interior is more than 0 (the default) then.....
     {
         SetPlayerInterior(playerid,GetPlayerInterior(id));//.....set the spectator's interior to that of the player being spectated.
     }
     if(GetPlayerVirtualWorld(id) > 0)//If the player's virtual world is more than 0 (the default) then.....
     {
         SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));//.....set the spectator's virtual world to that of the player being spectated.
     }
     PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));// Now remember we checked if the player is in a vehicle, well if they're in a vehicle then we'll spec the vehicle.
    }
    else// If they're not in a vehicle, then we'll spec the player.
    {
     if(GetPlayerInterior(id) > 0)
     {
         SetPlayerInterior(playerid,GetPlayerInterior(id));
     }
     if(GetPlayerVirtualWorld(id) > 0)
     {
         SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
     }
     PlayerSpectatePlayer(playerid,id);// Letting the spectator spec the person and not a vehicle.
   	}
    GetPlayerName(id, Name, sizeof(Name));//Getting the name of the player being spectated.
    format(String, sizeof(String),"You have started to spectate %s.",Name);// Formatting a string to send to the spectator.
    SendClientMessage(playerid,0x0080C0FF,String);//Sending the formatted message to the spectator.
    IsSpecing[playerid] = 1;// Just saying that the spectator has begun to spectate someone.
    IsBeingSpeced[id] = 1;// Just saying that a player is being spectated (You'll see where this comes in)
    spectatorid[playerid] = id;// Saving the spectator's id into this variable.
    return 1;// Returning 1 - saying that the command has been sent.
}

COMMAND:specoff(playerid, params[])
{
    if(!IsPlayerAdmin(playerid))return 0;// This checks if the player is logged into RCON, if not it will return 0; (Showing "SERVER: Unknown Command") You can replace it with your own admin check.
    if(IsSpecing[playerid] == 0)return SendClientMessage(playerid,Grey,"You are not spectating anyone.");
    TogglePlayerSpectating(playerid, 0);//Toggling spectate mode, off. Note: Once this is called, the player will be spawned, there we'll need to reset their positions, virtual world and interior to where they typed '/spec'
    return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
    if(IsBeingSpeced[playerid] == 1)//If the player being spectated, disconnects, then turn off the spec mode for the spectator.
    {
        foreach(Player,i)
        {
            if(spectatorid[i] == playerid)
            {
                TogglePlayerSpectating(i,false);// This justifies what's above, if it's not off then you'll be either spectating your connect screen, or somewhere in blueberry (I don't know why)
            }
        }
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    if(IsBeingSpeced[playerid] == 1)//If the player being spectated, dies, then turn off the spec mode for the spectator.
    {
        foreach(Player,i)
        {
            if(spectatorid[i] == playerid)
            {
                TogglePlayerSpectating(i,false);// This justifies what's above, if it's not off then you'll be either spectating your connect screen, or somewhere in blueberry (I don't know why)
            }
        }
    }
    return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)// If the player's state changes to a vehicle state we'll have to spec the vehicle.
    {
        if(IsBeingSpeced[playerid] == 1)//If the player being spectated, enters a vehicle, then let the spectator spectate the vehicle.
        {
            foreach(Player,i)
            {
                if(spectatorid[i] == playerid)
                {
                    PlayerSpectateVehicle(i, GetPlayerVehicleID(playerid));// Letting the spectator, spectate the vehicle of the player being spectated (I hope you understand this xD)
                }
            }
        }
    }
    if(newstate == PLAYER_STATE_ONFOOT)
    {
        if(IsBeingSpeced[playerid] == 1)//If the player being spectated, exists a vehicle, then let the spectator spectate the player.
        {
            foreach(Player,i)
            {
                if(spectatorid[i] == playerid)
                {
                    PlayerSpectatePlayer(i, playerid);// Letting the spectator, spectate the player who exited the vehicle.
                }
            }
        }
    }
    return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)//This is called when a player's interior is changed.
{
    if(IsBeingSpeced[playerid] == 1)//If the player being spectated, changes an interior, then update the interior and virtualword for the spectator.
    {
        foreach(Player,i)
        {
            if(spectatorid[i] == playerid)
            {
                SetPlayerInterior(i,GetPlayerInterior(playerid));
                SetPlayerVirtualWorld(i,GetPlayerVirtualWorld(playerid));
            }
        }
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(IsSpecing[playerid] == 1)
    {
        SetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);// Remember earlier we stored the positions in these variables, now we're gonna get them from the variables.
        SetPlayerInterior(playerid,Inter[playerid]);//Setting the player's interior to when they typed '/spec'
        SetPlayerVirtualWorld(playerid,vWorld[playerid]);//Setting the player's virtual world to when they typed '/spec'
        IsSpecing[playerid] = 0;//Just saying you're free to use '/spec' again YAY :D
        IsBeingSpeced[spectatorid[playerid]] = 0;//Just saying that the player who was being spectated, is not free from your stalking >:D
    }
    return 1;
}
Reply
#2

pawn Код:
COMMAND:spec(playerid, params[])
{
    new id;// This will hold the ID of the player you are going to be spectating.
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "You are not authorized to use this command.");
    if(!IsPlayerAdmin(playerid))return 0;// This checks if the player is logged into RCON, if not it will return 0; (Showing "SERVER: Unknown Command") You can replace it with your own admin check.
    if(sscanf(params,"u", id))return SendClientMessage(playerid, Grey, "Usage: /spec [id]");// Now this is where we use sscanf to check if the params were filled, if not we'll ask you to fill them
    if(id == playerid)return SendClientMessage(playerid,Grey,"You cannot spec yourself.");// Just making sure.
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, Grey, "Player not found!");// This is to ensure that you don't fill the param with an invalid player id.
    if(IsSpecing[playerid] == 1)return SendClientMessage(playerid,Grey,"You are already specing someone.");// This will make you not automatically spec someone else by mistake.
    GetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);// This is getting and saving the player's position in a variable so they'll respawn at the same place they typed '/spec'
    Inter[playerid] = GetPlayerInterior(playerid);// Getting and saving the interior.
    vWorld[playerid] = GetPlayerVirtualWorld(playerid);//Getting and saving the virtual world.
    TogglePlayerSpectating(playerid, true);// Now before we use any of the 3 functions listed above, we need to use this one. It turns the spectating mode on.
    if(IsPlayerInAnyVehicle(id))//Checking if the player is in a vehicle.
    {
     if(GetPlayerInterior(id) > 0)//If the player's interior is more than 0 (the default) then.....
     {
         SetPlayerInterior(playerid,GetPlayerInterior(id));//.....set the spectator's interior to that of the player being spectated.
     }
     if(GetPlayerVirtualWorld(id) > 0)//If the player's virtual world is more than 0 (the default) then.....
     {
         SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));//.....set the spectator's virtual world to that of the player being spectated.
     }
     PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));// Now remember we checked if the player is in a vehicle, well if they're in a vehicle then we'll spec the vehicle.
    }
    else// If they're not in a vehicle, then we'll spec the player.
    {
     if(GetPlayerInterior(id) > 0)
     {
         SetPlayerInterior(playerid,GetPlayerInterior(id));
     }
     if(GetPlayerVirtualWorld(id) > 0)
     {
         SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
     }
     PlayerSpectatePlayer(playerid,id);// Letting the spectator spec the person and not a vehicle.
    }
    GetPlayerName(id, Name, sizeof(Name));//Getting the name of the player being spectated.
    format(String, sizeof(String),"You have started to spectate %s.",Name);// Formatting a string to send to the spectator.
    SendClientMessage(playerid,0x0080C0FF,String);//Sending the formatted message to the spectator.
    IsSpecing[playerid] = 1;// Just saying that the spectator has begun to spectate someone.
    IsBeingSpeced[id] = 1;// Just saying that a player is being spectated (You'll see where this comes in)
    spectatorid[playerid] = id;// Saving the spectator's id into this variable.
    return 1;// Returning 1 - saying that the command has been sent.
}
Reply
#3

Quote:
Originally Posted by Private200
Посмотреть сообщение
pawn Код:
COMMAND:spec(playerid, params[])
{
    new id;// This will hold the ID of the player you are going to be spectating.
    if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "You are not authorized to use this command.");
    if(!IsPlayerAdmin(playerid))return 0;// This checks if the player is logged into RCON, if not it will return 0; (Showing "SERVER: Unknown Command") You can replace it with your own admin check.
    if(sscanf(params,"u", id))return SendClientMessage(playerid, Grey, "Usage: /spec [id]");// Now this is where we use sscanf to check if the params were filled, if not we'll ask you to fill them
    if(id == playerid)return SendClientMessage(playerid,Grey,"You cannot spec yourself.");// Just making sure.
    if(id == INVALID_PLAYER_ID)return SendClientMessage(playerid, Grey, "Player not found!");// This is to ensure that you don't fill the param with an invalid player id.
    if(IsSpecing[playerid] == 1)return SendClientMessage(playerid,Grey,"You are already specing someone.");// This will make you not automatically spec someone else by mistake.
    GetPlayerPos(playerid,SpecX[playerid],SpecY[playerid],SpecZ[playerid]);// This is getting and saving the player's position in a variable so they'll respawn at the same place they typed '/spec'
    Inter[playerid] = GetPlayerInterior(playerid);// Getting and saving the interior.
    vWorld[playerid] = GetPlayerVirtualWorld(playerid);//Getting and saving the virtual world.
    TogglePlayerSpectating(playerid, true);// Now before we use any of the 3 functions listed above, we need to use this one. It turns the spectating mode on.
    if(IsPlayerInAnyVehicle(id))//Checking if the player is in a vehicle.
    {
     if(GetPlayerInterior(id) > 0)//If the player's interior is more than 0 (the default) then.....
     {
         SetPlayerInterior(playerid,GetPlayerInterior(id));//.....set the spectator's interior to that of the player being spectated.
     }
     if(GetPlayerVirtualWorld(id) > 0)//If the player's virtual world is more than 0 (the default) then.....
     {
         SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));//.....set the spectator's virtual world to that of the player being spectated.
     }
     PlayerSpectateVehicle(playerid,GetPlayerVehicleID(id));// Now remember we checked if the player is in a vehicle, well if they're in a vehicle then we'll spec the vehicle.
    }
    else// If they're not in a vehicle, then we'll spec the player.
    {
     if(GetPlayerInterior(id) > 0)
     {
         SetPlayerInterior(playerid,GetPlayerInterior(id));
     }
     if(GetPlayerVirtualWorld(id) > 0)
     {
         SetPlayerVirtualWorld(playerid,GetPlayerVirtualWorld(id));
     }
     PlayerSpectatePlayer(playerid,id);// Letting the spectator spec the person and not a vehicle.
    }
    GetPlayerName(id, Name, sizeof(Name));//Getting the name of the player being spectated.
    format(String, sizeof(String),"You have started to spectate %s.",Name);// Formatting a string to send to the spectator.
    SendClientMessage(playerid,0x0080C0FF,String);//Sending the formatted message to the spectator.
    IsSpecing[playerid] = 1;// Just saying that the spectator has begun to spectate someone.
    IsBeingSpeced[id] = 1;// Just saying that a player is being spectated (You'll see where this comes in)
    spectatorid[playerid] = id;// Saving the spectator's id into this variable.
    return 1;// Returning 1 - saying that the command has been sent.
}
I try now and i tell you after if work.
It don't work, if i set my admin level to 0 say "You are not authorizated to use this command!", if i set my admin level to 1/2/3/4/5 or 6 it say "You are not authorizated to use this command!". Why? How can i fix this?
Reply
#4

Don't work Private200 method, if i'm admin it say You are not authorizated to use this command, Help me please, anyone?
Reply
#5

pawn Код:
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "You are not authorized to use this command.");
Change it to

pawn Код:
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, -1, "You are not authorized to use this command."); //If the players admin level is 0
Reply
#6

Quote:
Originally Posted by Kyance
Посмотреть сообщение
pawn Код:
if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, -1, "You are not authorized to use this command.");
Change it to

pawn Код:
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, -1, "You are not authorized to use this command."); //If the players admin level is 0
Idk why, but i have same problem, i tested with all admins level (from 1 to 6) and it say You are not authorized to use this command.
Reply
#7

If that's a filterscript the player variables are not shared with the main gamemode. You have to load them individually just like you do in the main gamemode. Your pAdmin will be 5 in the main gamemode and 0 at the filterscript it's called at.
Reply
#8

Instead of
pawn Код:
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, -1, "You are not authorized to use this command.");
Try to use
pawn Код:
if(PlayerInfo[playerid][pAdmin] >= 1) return SendClientMessage(playerid, -1, "You are not authorized to use this command.");
Try it.
Reply
#9

Quote:
Originally Posted by CuervO
Посмотреть сообщение
If that's a filterscript the player variables are not shared with the main gamemode. You have to load them individually just like you do in the main gamemode. Your pAdmin will be 5 in the main gamemode and 0 at the filterscript it's called at.
I can't add to gamemode, when i try to compile my gamemode it say pawno crashed
Reply
#10

Quote:
Originally Posted by rakshith122
Посмотреть сообщение
Instead of
pawn Код:
if(PlayerInfo[playerid][pAdmin] == 0) return SendClientMessage(playerid, -1, "You are not authorized to use this command.");
Try to use
pawn Код:
if(PlayerInfo[playerid][pAdmin] >= 1) return SendClientMessage(playerid, -1, "You are not authorized to use this command.");
Try it.
So, admins who are Level 1 and higher would get the message?
wow, i'm pretty sure he wants the opposite, that players get the message.

@Robert:
Try pasting the script ( spec ) into your game-mode, and check it via a Bracket finder or something
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)