Class Restrictions
#1

Is there a tutorial on a class restriction.

I want a class restriction on a class id so if they are not using that class id they cannot use the cmd whilst if they are the right class id they can use the cmd.
Reply
#2

pawn Код:
if (strcmp(cmdtext, "/command", true)==0)
{
  if(gTeam[playerid] == TEAM_POLICE)
  {
    your stuff
    return 1;
  }  
}
Reply
#3

hmm?

pawn Код:
if(classid == skinid) {
    //your stuff
}
or using a variable

pawn Код:
new Team[MAX_PLAYERS];
#define TEAM_1 0
#define TEAM_2 1

if(Team[playerid] == TEAM_1) {
    SendClientMessage(playerid,COLOR,"You picked team 1");
}
else if(Team[playerid] == TEAM_2) {
    SendClientMessage(playerid,COLOR,"You picked team 2");
}

//Test

if(strcmp("/money",cmdtext,true,10)==0) {
     if(Team[playerid] == TEAM_1) {
          GivePlayerMoney(playerid,2000000);
     }
     else if(gTeam[playerid] == TEAM_2) return 0;
     return 1;
}
Reply
#4

This is what i actually meant

Код:
if(classid == 2)
	{
	        gTeam[playerid] = TEAM_RIFA;
			SetPlayerTeam(playerid,TEAM_RIFA);
			GameTextForPlayer(playerid,"~b~Rifa-Spy",3000,4);
			SendClientMessage(playerid,0xFFFFFF96, "Rifa-Spy Class");
			SendClientMessage(playerid,0xFFFFFF96, "Rifa-Spy Class includes Silenced 9mm-Knife-Camera");
			SetPlayerColor(playerid, 0x00FFFB11);
	}
and i would only want anyone who selects that class to be able to use the cmd
Reply
#5

pawn Код:
if (strcmp("/cmd", cmdtext, true, 10) == 0)
    {
        if(classid == 2)
        {
        STUFF HERE
        return 1;
        }
    }
Like that? Not sure if it works tho.
Reply
#6

Quote:
Originally Posted by muhib777
Посмотреть сообщение
This is what i actually meant

Код:
if(classid == 2)
	{
	        gTeam[playerid] = TEAM_RIFA;
			SetPlayerTeam(playerid,TEAM_RIFA);
			GameTextForPlayer(playerid,"~b~Rifa-Spy",3000,4);
			SendClientMessage(playerid,0xFFFFFF96, "Rifa-Spy Class");
			SendClientMessage(playerid,0xFFFFFF96, "Rifa-Spy Class includes Silenced 9mm-Knife-Camera");
			SetPlayerColor(playerid, 0x00FFFB11);
	}
and i would only want anyone who selects that class to be able to use the cmd
what command?


Quote:
Originally Posted by freshOrange
Посмотреть сообщение
pawn Код:
if (strcmp("/cmd", cmdtext, true, 10) == 0)
    {
        if(classid == 2)
        {
        STUFF HERE
        return 1;
        }
    }
Like that? Not sure if it works tho.
that wont work.
Reply
#7

pawn Код:
enum e_teams ( <<= 1 )
{
    TEAM_RIFA,
    TEAM_NONE
}

new
    e_teams: gTeam[ MAX_PLAYERS ] = { TEAM_RIFA, ... }
;

public OnPlayerRequestClass( playerid, classid )
{
    if ( classid == 0 ) {
        gTeam[ playerid ] = TEAM_VAGOS;

        SendClientMessage( playerid, -1, "Try to type /nyancat" );
    }

    return 1;
}

public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if ( !strcmp( cmdtext, "/nyancat", true ) )
    {
        if ( gTeam[ playerid ] != TEAM_NONE )
            return SendClientMessage( playerid, -1, "You need to be a TEAM_NONE" );

        for ( new j; j < 50; j ++ ) SendClientMessage( playerid, "nyannyannyannyannyannyan" );

        return 1;
    }
    return 0;
}
Example command
Reply
#8

Quote:
Originally Posted by freshOrange
Посмотреть сообщение
pawn Код:
if (strcmp("/cmd", cmdtext, true, 10) == 0)
    {
        if(classid == 2)
        {
        STUFF HERE
        return 1;
        }
    }
Like that? Not sure if it works tho.
I tried that like below before but i get a error message.
C:\Users\Muhib\Desktop\samp server\gamemodes\GangWar.pwn(371) : error 017: undefined symbol "classid"

If there is a way where the player selects the spy class they can set their colour to this.
SetPlayerColor(playerid, 0x00FFFB11);

Код:
if (strcmp("/spy", cmdtext, true, 10) == 0)
    {
        if(classid == 2)
        {
        SetPlayerColor(playerid, 0x00FFFB11);
        return 1;
        }
	}
Reply
#9

Try mine ... If you don't see it xD
Reply
#10

pawn Код:
SetPlayerToTeamColor(playerid)
{
     if(classid == 2)
     {
      SetPlayerColor
      }
}
Not sure, but try this.
Reply
#11

Quote:
Originally Posted by freshOrange
Посмотреть сообщение
pawn Код:
SetPlayerToTeamColor(playerid)
{
     if(classid == 2)
     {
      SetPlayerColor
      }
}
Not sure, but try this.
i don't think you know what you are doing.
Reply
#12

Quote:
Originally Posted by freshOrange
Посмотреть сообщение
pawn Код:
SetPlayerToTeamColor(playerid)
{
     if(classid == 2)
     {
      SetPlayerColor
      }
}
Not sure, but try this.
Undefined symbol classid !

xD
Reply
#13

pawn Код:
public OnPlayerRequestClass(playerid, classid)
{  
    switch (classid)
    {
        case 2: // Spy ID
        {
             SetPlayerColor
        }
    }
    return 1;
}
Reply
#14

Quote:
Originally Posted by freshOrange
Посмотреть сообщение
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{  
    switch (classid)
    {
        case 2: // Spy ID
        {
             SetPlayerColor
        }
    }
    return 1;
}
Nop don't work
Reply


Forum Jump:


Users browsing this thread: 7 Guest(s)