police only
#1

how would you make this fs cops /cia/army/fbi only .

Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

new Float:x, Float:y, Float:z;
new Float:rz;
new spike;
new Spikes;

#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	return 1;
}

public OnFilterScriptExit()
{
	DestroyObject(spike);
	return 1;
}
#endif

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/spike", cmdtext))
    {
        if(Spikes == 0)
        {
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid, rz);
        spike = CreateObject(2892, x, y, z-0.8, 0, 0, rz+90);
        SendClientMessage(playerid, 0xFFFFFFFF, "Spike Strip Set!");
        Spikes = 1;
        }
        else
        {
        SendClientMessage(playerid, 0xFFFFFFFF, "There Is Already A Spike Strip Set!");
        }
        return 1;
    }
	return 0;
}

encode_tires(tire1, tire2, tire3, tire4) {

	return tire1 | (tire2 << 1) | (tire3 << 2) | (tire4 << 3);
}

public OnPlayerUpdate(playerid)
{
	if(IsPlayerInAnyVehicle(playerid))
	{
	if(IsPlayerInRangeOfPoint(playerid, 3.0, x, y, z))
	{
    UpdateVehicleDamageStatus(GetPlayerVehicleID(playerid), 0, 0, 0, encode_tires(1, 1, 1, 1));
    DestroyObject(spike);
    Spikes = 0;
    }
    }
    return 1;
    }
Reply
#2

Create a variable that represents a player who is a cop. Then make a condition that only the police players can use this command, I guess.
Reply
#3

Which part of the script? also use [ pawn ] tags [ /pawn ] without spaces when pasting code.

When you have found out do this:
pawn Code:
//top of script
#define cop 1
new gTeam[MAX_PLAYERS];

if(gTeam[playerid] == cop)
{
    //code you want only for cops
}
Reply
#4

It depends on the variable. Say you had "PlayerInfo[playerid][pTeam]" then you just need to add a if statement:

pawn Code:
if(PlayerInfo[playerid][pTeam] == 1) { // Change "PlayerInfo[playerid][pTeam]" to the variable and the number to resemble to team. 1 could be CIA/FBI...

}
Then if you want text to be replied add a else statement:
pawn Code:
} // Closing bracket of the if statement
else {
    SendClientMessage(playerid, -1, "Cops only.");
}
So if I was to join it up with the code you have:

pawn Code:
if (!strcmp("/spike", cmdtext))
{
    if(PlayerInfo[playerid][pTeam] == 1) {
        if(Spikes == 0)
        {
            GetPlayerPos(playerid,x,y,z);
            GetPlayerFacingAngle(playerid, rz);
            spike = CreateObject(2892, x, y, z-0.8, 0, 0, rz+90);
            SendClientMessage(playerid, 0xFFFFFFFF, "Spike Strip Set!");
            Spikes = 1;
        }
        else
        {
            SendClientMessage(playerid, 0xFFFFFFFF, "There Is Already A Spike Strip Set!");
        }
    }
    else {
        SendClientMessage(playerid, -1, "Cops only.");
    }
return 1;
Hopefully you understand...
Reply
#5

i think so here what my server has .

SetPlayerTeamFromClass(playerid, classid)
{
if(classid >= 0 && classid <= 5) gTeam[playerid] = COP;
else if(classid == 6) gTeam[playerid] = FBI;
else if(classid == 7) gTeam[playerid] = SWAT;
else if(classid == gTeam[playerid] = ARMY;
else if(classid >= 9 && classid <= 11) gTeam[playerid] = Medic;
else if(classid >= 12 && classid <= 30) gTeam[playerid] = CIVILIAN;
}
Reply
#6

Quote:
Originally Posted by Edward d
View Post
i think so here what my server has .

SetPlayerTeamFromClass(playerid, classid)
{
if(classid >= 0 && classid <= 5) gTeam[playerid] = COP;
else if(classid == 6) gTeam[playerid] = FBI;
else if(classid == 7) gTeam[playerid] = SWAT;
else if(classid == gTeam[playerid] = ARMY;
else if(classid >= 9 && classid <= 11) gTeam[playerid] = Medic;
else if(classid >= 12 && classid <= 30) gTeam[playerid] = CIVILIAN;
}
Then you can try this..
pawn Code:
if (!strcmp("/spike", cmdtext))
{
    if(gTeam[playerid] == COP) {
Reply
#7

ok i got it in but i get a error on the #define gteam so just a guess maybe just add #define gteam like in the post above ill let you knoe how it goes
Reply
#8

Code:
// This is a comment
// uncomment the line below if you want to write a filterscript
#define FILTERSCRIPT

new Float:x, Float:y, Float:z;
new Float:rz;
new spike;
new Spikes;

#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
	return 1;
}

public OnFilterScriptExit()
{
	DestroyObject(spike);
	return 1;
}
#endif

public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/spike", cmdtext))
    {   
        if(gTeam[playerid] == COP) }

        if(Spikes == 0)
        {
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid, rz);
        spike = CreateObject(2892, x, y, z-0.8, 0, 0, rz+90);
        SendClientMessage(playerid, 0xFFFFFFFF, "Spike Strip Set!");
        Spikes = 1;
        }
        else
        {
        SendClientMessage(playerid, 0xFFFFFFFF, "There Is Already A Spike Strip Set!");
       }
Get undefined gTeAM
IF I ADD #define gTeam at top i then get a new error

not sure what to do think its time to stick to playing and let others do this stuff lol
Reply
#9

Quote:
Originally Posted by Edward d
View Post
Code:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (!strcmp("/spike", cmdtext))
    {   
        if(gTeam[playerid] == COP) }

        if(Spikes == 0)
        {
        GetPlayerPos(playerid,x,y,z);
        GetPlayerFacingAngle(playerid, rz);
        spike = CreateObject(2892, x, y, z-0.8, 0, 0, rz+90);
        SendClientMessage(playerid, 0xFFFFFFFF, "Spike Strip Set!");
        Spikes = 1;
        }
        else
        {
        SendClientMessage(playerid, 0xFFFFFFFF, "There Is Already A Spike Strip Set!");
       }
That bracket dear. It's open and not close.
Reply
#10

so do i need to open one for the if(spikes == 0)?
like this .
Code:
if (!strcmp("/spike", cmdtext))
    {   
        if(gTeam[playerid] == COP) }
   {   
        if(Spikes == 0)
        }
and thx for pointing that out btw
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)