[HELP] My Classes Wont Spawn With Its Specific Colour Anymore???
#1

Ok this is weird and have tried everything :S

The problem is TEAM_COPS are not showing as blue markers anymore and TEAM_AGENT skin 287 is not showing green after i added more classes (CLASS_MEDIC || CLASS_KIDNAP || CLASS_RAPIST)

Before i added these new classes they all showed there specific colors.

Now not event Army shows green they all show white

Here are the callbacks used and everything else so u can see:

pawn Код:
#define TEAM_CIVILIAN 0
#define TEAM_COPS 1
#define TEAM_AGENT 2

#define CLASS_MEDIC 3
#define CLASS_KIDNAP 4
#define CLASS_RAPIST 5

public SetPlayerTeamFromClass(playerid, classid)
{
    switch(classid)
    {
        case 0..10:
        {
            gTeam[playerid] = TEAM_COPS;
            GameTextForPlayer(playerid, "~b~Cops", 2000, 5);
        }
        case 11..14:
        {
            gTeam[playerid] = TEAM_AGENT;
            GameTextForPlayer(playerid, "~w~CIA", 2000, 5);
        }
        case 15:
        {
            gTeam[playerid] = TEAM_AGENT;
            GameTextForPlayer(playerid, "~g~Army", 2000, 5);
        }
        case 16..104:
        {
            gTeam[playerid] = TEAM_CIVILIAN;
            GameTextForPlayer(playerid, "~r~Civilians", 2000, 5);
        }
        case 105..107:
        {
            gTeam[playerid] = CLASS_MEDIC;
            GameTextForPlayer(playerid, "~w~Medic", 2000, 5);
        }
        case 108:
        {
            gTeam[playerid] = CLASS_KIDNAP;
            GameTextForPlayer(playerid, "~r~Kidnapper", 2000, 5);
        }
        case 109:
        {
            gTeam[playerid] = CLASS_RAPIST;
            GameTextForPlayer(playerid, "~r~Rapist", 2000, 5);
        }
    }
}


public OnPlayerUpdate(playerid)
{
    if(gTeam[playerid] == TEAM_CIVILIAN || CLASS_KIDNAP || CLASS_RAPIST)
    {
        if(GetPlayerWantedLevel(playerid) == 0)
        {
            SetPlayerColor(playerid,WHITE);
        }
        else if(GetPlayerWantedLevel(playerid) >= 1 && GetPlayerWantedLevel(playerid) <= 3)
        {
            SetPlayerColor(playerid,0xFFFF00FF);
        }
        else if(GetPlayerWantedLevel(playerid) >= 4 && GetPlayerWantedLevel(playerid) <= 8)
        {
            SetPlayerColor(playerid,0xFF8000FF);
        }
        else if(GetPlayerWantedLevel(playerid) >= 9)
        {
            SetPlayerColor(playerid,0xFF0000FF);
        }
    }
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_COPS)
    {
        SetPlayerWantedLevel(playerid, 0);
        SetPlayerTeam(playerid, 0);
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "You Are A Cop You Job Is To /ar Oranges And Reds And /tk Yellows!");
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "Use /cmds And Read /rules Before Playing! Use /co For Cop Radio");
        GivePlayerWeapon(playerid, 32, 400);
        SetPlayerColor(playerid,BLUE);
        new rand = random(sizeof(copPlayerSpawns));
        SetPlayerPos(playerid, copPlayerSpawns[rand][0], copPlayerSpawns[rand][1], copPlayerSpawns[rand][2]);
        SetPlayerFacingAngle(playerid, copPlayerSpawns[rand][3]);
        SetPlayerArmour(playerid, 100);
    }
    else if(gTeam[playerid] == TEAM_AGENT)
    {
        SetPlayerWantedLevel(playerid, 0);
        SetPlayerTeam(playerid, 0);
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "You Are A Cop You Job Is To /ar Oranges And Reds And /tk Yellows!");
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "Use /cmds And Read /rules Before Playing! Use /ac For Agent Radio");
        GivePlayerWeapon(playerid, 32, 400);
        if(GetPlayerSkin(playerid) == 287)
        {
            SetPlayerPos(playerid, 267.3403, 1941.5496, 17.6406);
            SetPlayerColor(playerid, GREEN);
        }
        else if(GetPlayerSkin(playerid) == 163 || 164 || 165 || 166)
        {
            SetPlayerPos(playerid, 962.3979, 1802.8895, 8.8516);
            SetPlayerColor(playerid, WHITE);
        }
    }
    else if(gTeam[playerid] == TEAM_CIVILIAN)
    {
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "You Are A Robber Your Job Is To Rob Stores And Casinos! Use /rob To Rob Players!");
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "Don't Get Caught! You Will Be Sent To Jail!");
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "Use /cmds And Read /rules Before Playing! Use /rc For Robber Chat!");
        SetPlayerColor(playerid,WHITE);
        new rand = random(sizeof(civilianPlayerSpawns));
        SetPlayerPos(playerid, civilianPlayerSpawns[rand][0], civilianPlayerSpawns[rand][1], civilianPlayerSpawns[rand][2]);
        SetPlayerFacingAngle(playerid, civilianPlayerSpawns[rand][3]);
    }
    else if(gTeam[playerid] == CLASS_MEDIC)
    {
        SetPlayerWantedLevel(playerid, 0);
        SetPlayerTeam(playerid, 3);
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "You Are A Medic Your Job Is To Heal Wounded Players! Use /healme To Heal Yourself!");
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "Use /cmds And Read /rules Before Playing! Use /mc For Medic Radio!");
        SetPlayerColor(playerid,WHITE);
        SetPlayerPos(playerid,1607.3618,1820.2750,10.8280);
    }
    else if(gTeam[playerid] == CLASS_KIDNAP)
    {
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "You Are A Kidnapper! You Job Is To Kidnap Players! Use /tie In A Car To Kidnap Someone!");
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "Use /cmds And Read /rules Before Playing! Use /rc For Robber Chat!");
        SetPlayerColor(playerid,WHITE);
        new rand = random(sizeof(civilianPlayerSpawns));
        SetPlayerPos(playerid, civilianPlayerSpawns[rand][0], civilianPlayerSpawns[rand][1], civilianPlayerSpawns[rand][2]);
        SetPlayerFacingAngle(playerid, civilianPlayerSpawns[rand][3]);
    }
    else if(gTeam[playerid] == CLASS_RAPIST)
    {
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "You Are A Rapist Your Job Is To Rape Players! Use /rape To Rape Somebody!");
        SendClientMessage(playerid, COLOR_LIGHTGREEN, "Use /cmds And Read /rules Before Playing! Use /rc For Robber Chat!");
        SetPlayerColor(playerid,WHITE);
        new rand = random(sizeof(civilianPlayerSpawns));
        SetPlayerPos(playerid, civilianPlayerSpawns[rand][0], civilianPlayerSpawns[rand][1], civilianPlayerSpawns[rand][2]);
        SetPlayerFacingAngle(playerid, civilianPlayerSpawns[rand][3]);
    }
        return 1;
}

public SetPlayerToTeamColor(playerid)
{
    if(gTeam[playerid] == TEAM_COPS)
    {
        SetPlayerColor(playerid, BLUE);
    }
    else if(gTeam[playerid] == TEAM_CIVILIAN)
    {
        SetPlayerColor(playerid, WHITE);
    }
    else if(gTeam[playerid] == CLASS_MEDIC)
    {
        SetPlayerColor(playerid, WHITE);
    }
    else if(gTeam[playerid] == CLASS_KIDNAP)
    {
        SetPlayerColor(playerid, WHITE);
    }
    else if(gTeam[playerid] == CLASS_RAPIST)
    {
        SetPlayerColor(playerid, WHITE);
    }
}
Thanks in advanced!
Reply
#2

In OnPlayerUpdate where it says:

pawn Код:
if(gTeam[playerid] == TEAM_CIVILIAN || CLASS_KIDNAP || CLASS_RAPIST)
Try changing it to:

pawn Код:
if(gTeam[playerid] == TEAM_CIVILIAN || gTeam[playerid] == CLASS_KIDNAP || gTeam[playerid] == CLASS_RAPIST)
On a related note, I strongly advise you stop using OnPlayerUpdate as it checks as frequently as the server contacts the player, so roughly as fast as their ping. That will cause a large load and for something like that, it seems like you would benefit from changing a player's color when you change the wanted level instead of changing the wanted level and using OnPlayerUpdate to finish the color change. I stopped looking at the script when I found this, so let me know if that does not work, if I don't help, someone here will.
Reply
#3

@SpartanLegends

Dude thanks but i dont even know why i added OnPlayerUpdate thats just for these classes
pawn Код:
if(gTeam[playerid] == TEAM_CIVILIAN || CLASS_KIDNAP || CLASS_RAPIST)
to be able to gain wanted levels from reobberys its not really related to the problem,Everything else works fine you spawn with the class but it just wont set the color for some reason :S thay all show as white :S

Any ideas guys?
Reply
#4

The problem I was addressing was the fact that when it goes to:

pawn Код:
if(gTeam[playerid] == TEAM_CIVILIAN || CLASS_KIDNAP || CLASS_RAPIST)
It does not just do that for those classes because in the OR statement it considers it just as "CLASS_KIDNAP", so as long as CLASS_KIDNAP or CLASS_RAPIST exists, it will ALWAYS continue with the if statement as true, so it checks the wanted level and sets the color accordingly, that would explain why your police change to white.
Reply
#5

wow i see what u mean now...

I cant believe i didnt add the
Код:
gTeam[playerid]
xD -.-

Thanks dude
Reply
#6

I just hope it works.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)