Score required for certain team ?
#1

Hello guys.. I'm having big problem today with my teams.. I made 4 of them, Cops, Army, Civilian and Terrorist..
So what i want to do , i want to make an condition for players who want to be in team Army.. Condition would be 50 score.. so okey, lets get started .. here is the code
pawn Код:
public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerTeamFromClass(playerid, classid);
    SetPlayerPos(playerid, 1491.4349,-871.7689,60.0094);
    SetPlayerFacingAngle(playerid,311.0488);
    SetPlayerCameraPos(playerid, 1496.0518,-867.3990,60.9751);
    SetPlayerCameraLookAt(playerid, 1491.4349,-871.7689,60.0094);
    pClass[playerid] = classid;
    switch(classid)
    {
        case 0,1,2,3:
        {
            GameTextForPlayer(playerid, "~b~POLICE OFFICER", 3000, 4);
        }
        case 4:
        {
            GameTextForPlayer(playerid, "~g~ARMY", 3000, 4);
        }
        case 5,6,7,8,9,10,11,12:
        {
            GameTextForPlayer(playerid, "~y~CIVIL", 3000, 4);
        }
        case 13:
        {
            GameTextForPlayer(playerid, "~r~TERRORIST", 3000, 4);
        }
    }
    return 1;
}
SetPlayerTeamFromClass(playerid, classid)
{

    switch(classid)
    {
        case 0,1,2,3:
        {
            gTeam[playerid] = TEAM_COP;

        }
        case 4:
        {
            gTeam[playerid] = TEAM_ARMY;

        }
        case 5,6,7,8,9,10,11,12:
        {
            gTeam[playerid] = TEAM_CIVIL;

        }
        case 13:
        {
            gTeam[playerid] = TEAM_TERRORIST;

        }
    }
    return 1;
}

SetPlayerToTeamColor(playerid)
{
    if(gTeam[playerid] == TEAM_COP)
    {
        SetPlayerColor(playerid,TEAM_COP_COLOR);
    }
    else if(gTeam[playerid] == TEAM_ARMY)
    {
        SetPlayerColor(playerid,TEAM_ARMY_COLOR);
    }
    else if(gTeam[playerid] == TEAM_CIVIL)
    {
        SetPlayerColor(playerid,TEAM_CIVIL_COLOR);
    }
    else if(gTeam[playerid] == TEAM_TERRORIST)
    {
        SetPlayerColor(playerid,TEAM_TERRORIST_COLOR);
    }
    return 1;
}
Okey, i gived you more then i needed, but i want to make all things clear about spawning.. So i tried everything i found on this forum, but everytime i tried to spawn as Army with 0 score , i would be spawned and i would get my error message even before i press spawn(shift) .. Then i done this way :
pawn Код:
public OnPlayerSpawn(playerid)
{
    if(gTeam[playerid] == TEAM_CIVIL)
    {
        new Random = random(sizeof(RandomSpawns));
        SetPlayerPos(playerid, RandomSpawns[Random][0], RandomSpawns[Random][1], RandomSpawns[Random][2]);
        SetPlayerFacingAngle(playerid, RandomSpawns[Random][3]);
        SetPlayerToTeamColor(playerid);
    }
    if(gTeam[playerid] == TEAM_ARMY && GetPlayerScore(playerid) <= 49)
    {
        SendClientMessage(playerid,-1, "My error message" );
        return 0;
    }

    SetPlayerToTeamColor(playerid);
    return 1;
}
So ,as i have read on samp wiki and forum, return 0; wont let player to spawn if he does not pass conditions i putted after if. But, again, i was spawned ,but this time i got my error message after spawning (That's progress !! )

Any ideas how can i fix this ?
Reply
#2

Place your score check under OnPlayerRequestSpawn and return 0 if the check fails.

Quote:

Called when a player attempts to spawn via class selection.

Reply
#3

Quote:
Originally Posted by Corekt
Посмотреть сообщение
Place your score check under OnPlayerRequestSpawn and return 0 if the check fails.
Thanks for fast answer , but that didn't help.. when i picked Army skin (not spawn jet) i got My error message, and i got stuck , i could not change my skin anymore by clicking or pressing LEFT and RIGHT arrows , whenever i pressed something i would get my error message again and again.. and of course i could spawn with 0 score.. :/
Reply
#4

Seems like you might be returning 0 somewhere in OnPlayerRequestClass. Can you show me what you have under OnPlayerRequestClass and OnPlayerRequestSpawn?
Reply
#5

wow, i can't believe , i forgot to delete old if in OnPlayerRequestClass .. i guess im ready to take a nap ..
Anyway all works, thank you a lot man ! and u get rep ofc
LOCK THIS !
Reply
#6

OnPlayerRequestSpawn
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)