SA-MP Forums Archive
Class Restrictions - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Class Restrictions (/showthread.php?tid=269390)



Class Restrictions - muhib777 - 16.07.2011

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.


Re: Class Restrictions - freshOrange - 16.07.2011

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



Re: Class Restrictions - Kitten - 16.07.2011

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;
}



Re: Class Restrictions - muhib777 - 16.07.2011

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


Re: Class Restrictions - freshOrange - 16.07.2011

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


Re: Class Restrictions - Kitten - 16.07.2011

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.


Re: Class Restrictions - Basicz - 16.07.2011

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


Re: Class Restrictions - muhib777 - 16.07.2011

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;
        }
	}



Re: Class Restrictions - Basicz - 16.07.2011

Try mine ... If you don't see it xD


Re: Class Restrictions - freshOrange - 16.07.2011

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


Re: Class Restrictions - Kitten - 16.07.2011

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.


Re: Class Restrictions - Basicz - 16.07.2011

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

xD


Re: Class Restrictions - freshOrange - 16.07.2011

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



Re: Class Restrictions - muhib777 - 16.07.2011

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