Adding Teams
#1

i have a little problem with adding teams..
it's when i wonna put these:

Quote:

public OnPlayerRequestClass(playerid,classid)
{
SetPlayerTeamFromClass(playerid,classid);
}

it types me

Quote:

error 017: undefined symbol "SetPlayerTeamFromClass"

i've check some other scripits but couldn't find what's the problem
Reply
#2

https://sampwiki.blast.hk/wiki/PAWN_tutorial

About half way of the page.
Reply
#3

It means that SetPlayerTeamFromClass is an invalid function, you must create the function yourself. I have seen that function around here before, just search for it.
Reply
#4

and that's the exactly the tutorial wich i've foloved...
i've came to that part where i have to add this:
SetPlayerTeamFromClass(playerid,classid);
into this:
public OnPlayerRequestClass(playerid,classid)

and when i've done that.. it send's me an error
Reply
#5

Okay you need to add at the top of your script :

PHP код:
#define TEAM_GROVE 1 //This defines your teams
#define TEAM_BALLA 2 // this means that your not going to use the teams ID's , only TEAM_BALLA.
new gTeam[MAX_PLAYERS]; 
and under OnPlayerRequestClass , add

PHP код:
SetPlayerTeamFromClass(playerid,classid); // This sets the palyer team from class 
at the end of your script make this callback

SetPlayerTeamFromClass(playerid, classid)
PHP код:
{
    if (
classid == 0//This checks the class ID 
    
{
        
gTeam[playerid] = TEAM_GROVE//and this sets the player team
    
}
    else
    {
        
gTeam[playerid] = TEAM_BALLA;
    }

For more information go to

https://sampwiki.blast.hk/wiki/PAWN_tutorial_1
Reply
#6

hmm..
i've made this:

Quote:

#include <a_samp>
#define TEAM_GROVE 1
#define TEAM_BALLAS 2
#define TEAM_VAGOS 3
#define TEAM_ARMY 4
#define TEAM_AIRPORT 5
#define TEAM_COPS 6
#define TEAM_LSGOVERNMENT 7
#define TEAM_DANANGBOYS 8
#define TEAM_BIKERS 9
#define TEAM_GOLFERS 10
#define TEAM_GROVE_COLOR 0x00FF00AA
#define TEAM_BALLAS_COLOR 0xFF00FFAA
#define TEAM_VAGOS_COLOR 0xFFFF00AA
#define TEAM_AMRY_COLOR 0xAFAFAFAA
#define TEAM_AIRPORT_COLOR 0x33CCFFAA
#define TEAM_COPS_COLOR 0x0000BBAA
#define TEAM_LSGOVERNMENT_COLOR 0xFFFFFFAA
#define TEAM_DANANGBOYS_COLOR 0xFF4500AA
#define TEAM_BIKERS_COLOR 0xAA3333AA
#define TEAM_GOLFERS_COLOR 0x9ACD32AA
#if defined FILTERSCRIPT
new gTeam[MAX_PLAYERS];
SetPlayerTeamFromClass(playerid, classid)
{
if (classid == 0)
{
gTeam[playerid] = TEAM_GROVE;
}
if (classid == 1)
{
gTeam[playerid] = TEAM_BALLA;
}
if (classid == 2)
{
gTeam[playerid] = TEAM_VAGOS;
}
if (classid == 3)
{
gTeam[playerid] = TEAM_ARMY
}
if (classid == 4)
{
gTeam[playerid] = TEAM_AIRPORT
}
if (classid == 5)
{
gTeam[playerid] = TEAM_COPS
}

i have 10 teams.. not 2..
maybe i made a mistake somewhere here?
or should i put something above somewhere else in my script?
Reply
#7

You forgot to put SetPlayerTeamFromClass(playerid,classid); in OnPlayerRequestClass
also you need to put new gTeam[MAX_PLAYERS]; before #if defined FILTERSCRIPT

Here's the

PHP код:
#include <a_samp>
#define TEAM_GROVE 1
#define TEAM_BALLAS 2
#define TEAM_VAGOS 3
#define TEAM_ARMY 4
#define TEAM_AIRPORT 5
#define TEAM_COPS 6
#define TEAM_LSGOVERNMENT 7
#define TEAM_DANANGBOYS 8
#define TEAM_BIKERS 9
#define TEAM_GOLFERS 10
#define TEAM_GROVE_COLOR 0x00FF00AA
#define TEAM_BALLAS_COLOR 0xFF00FFAA
#define TEAM_VAGOS_COLOR 0xFFFF00AA
#define TEAM_AMRY_COLOR 0xAFAFAFAA
#define TEAM_AIRPORT_COLOR 0x33CCFFAA
#define TEAM_COPS_COLOR 0x0000BBAA
#define TEAM_LSGOVERNMENT_COLOR 0xFFFFFFAA
#define TEAM_DANANGBOYS_COLOR 0xFF4500AA
#define TEAM_BIKERS_COLOR 0xAA3333AA
#define TEAM_GOLFERS_COLOR 0x9ACD32AA
new gTeam[MAX_PLAYERS];
#if defined FILTERSCRIPT
public OnPlayerRequestClass(playeridclassid)
{
    
SetPlayerTeamFromClass(playerid,classid);
}
public 
OnPlayerSpawn(playeridclassid)
{
    
SetPlayerToTeamColour(playerid);
}
//at the end of the script
SetPlayerTeamFromClass(playeridclassid)
{
    if (
classid == 0//0 = to your first class that you made..
    
{
    
gTeam[playerid] = TEAM_GROVE;
    }
    if (
classid == 1)//1 = to the second class that you made..
    
{
    
gTeam[playerid] = TEAM_BALLA;
    }
    if (
classid == 2)
    {
    
gTeam[playerid] = TEAM_VAGOS;
    }
    if (
classid == 3)
    {
    
gTeam[playerid] = TEAM_ARMY
    
}
    if (
classid == 4)
    {
    
gTeam[playerid] = TEAM_AIRPORT
   
}
   if (
classid == 5)
   {
   
gTeam[playerid] = TEAM_COPS
   
}
}
SetPlayerToTeamColour(playerid)
{
    if(
gTeam[playerid] == TEAM_COPS)
    {
        
SetPlayerColor(playerid,TEAM_COPS_COLOR);
    }
    if(
gTeam[playerid] == TEAM_AIRPORT)
    {
        
SetPlayerColor(playerid,TEAM_AIRPORT_COLOR);

Hope that i helped you
Reply
#8

thx a lot dude
that realy helped..
big kiss from me :*
xD
Reply
#9

Quote:
Originally Posted by AVG_Free
Посмотреть сообщение
thx a lot dude
that realy helped..
big kiss from me :*
xD
No Problem.
Reply
#10

You could really optimize your code a little here, first of all, why are they all if statements? They could be else if statements, if one is true, the others can't be true in this case, so treat it like so! Also, considering the ID's of your teams are actually just the classid + 1, why not forget about the if statements altogether and just do something like this:

pawn Код:
SetPlayerTeamFromClass(playerid, classid)
{
    gTeam[playerid] = classid + 1;
}
Currently, that piece of code is achieving the exact same thing as your other piece of code. Since the ID of the teams are just the classid + 1!
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)