31.03.2014, 17:23
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
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 :
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 ?
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;
}
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;
}
Any ideas how can i fix this ?