case ClassPolice:
{
// Count the number of normal players (all classes except police) and count the amount of police players
new NormalPlayers, PolicePlayers, bool:CanSpawnAsCop = false;
// Block this check if PlayersBeforePolice is set to 0 (this allows anyone to join as police)
if (PlayersBeforePolice > 0)
{
// Loop through all players
for (new pid; pid < MAX_PLAYERS; pid++)
{
// Exclude this player, as he doesn't have a class yet, he's still choosing here
if (pid != playerid)
{
// Also exclude all players who are still in the class-selection screen, as they don't have a class selected yet
if (GetPlayerInterior(pid) != 14)
{
// Check if this player is logged in
if (APlayerData[pid][LoggedIn] == true)
{
// Count the amount of normal players and police players
switch (APlayerData[pid][PlayerClass])
{
case ClassPolice:
PolicePlayers++;
case ClassTruckDriver, ClassBusDriver, ClassPilot, ClassMafia, ClassCourier, ClassRoadWorker, ClassMarin, ClassTrain, ClassPizza, ClassAssistance, ClassTaxi, ClassBucheron:
NormalPlayers++;
}
}
}
}
}
// Check if there are less police players than allowed
// or allow police if less than 3 players
// or allow police for admin and modo
if (PolicePlayers < (NormalPlayers / PlayersBeforePolice) || NormalPlayers < 3 || APlayerData[playerid][PlayerLevel] == 5 || strcmp("trucking", APlayerData[playerid][PlayerName], true, 24) == 0)
CanSpawnAsCop = true; // There are less police players than allowed, so the player can choose this class
else
CanSpawnAsCop = false; // The maximum amount of police players has been reached, the player can't choose to be a cop
// Check if the player isn't allowed to spawn as police
if (CanSpawnAsCop == false)
{
// Let the player know the maximum amount of cops has been reached
GameTextForPlayer(playerid, "Le nombre maximum de policier est atteint", 5000, 4);
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Le nombre maximum de policier est atteint, sйlectionnez une autre classe");
return 0; // Don't allow the player to spawn as police player
}
}
if(Factions[APlayerData[playerid][Team]][Type] == 2)
{
// If the player has a wanted level
if (GetPlayerWantedLevel(playerid) > 0)
{
// Let the player know he cannot have a wanted level to join police
GameTextForPlayer(playerid, "Vous n'etes pas autorises", 5000, 4);
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Vous n'кtes pas autorisй а rejoindre la police lorsque vous кtes recherchй.");
return 0; // Don't allow the player to spawn as police player
}
Index = random(sizeof(ASpawnLocationsPolice));
x = ASpawnLocationsPolice[Index][SpawnX]; // Get the X-position for the spawnlocation
y = ASpawnLocationsPolice[Index][SpawnY]; // Get the Y-position for the spawnlocation
z = ASpawnLocationsPolice[Index][SpawnZ]; // Get the Z-position for the spawnlocation
Angle = ASpawnLocationsPolice[Index][SpawnAngle]; // Get the rotation-angle for the spawnlocation
format(Msg, 128, "{00FF00}Le joueur {FFFF00}%s{00FF00} a rejoint {FFFF00}la police", Name);
}
else {
GameTextForPlayer(playerid, "Vous n'etes pas autorises", 5000, 4);
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Cette classe est rйservй a la faction Flic.");
return 0; // Don't allow the player to spawn as police player
}
}
case ClassMafia:
{
if (Factions[APlayerData[playerid][Team]][Type] == 1)
{
Index = random(sizeof(ASpawnLocationsMafia));
x = ASpawnLocationsMafia[Index][SpawnX]; // Get the X-position for the spawnlocation
y = ASpawnLocationsMafia[Index][SpawnY]; // Get the Y-position for the spawnlocation
z = ASpawnLocationsMafia[Index][SpawnZ]; // Get the Z-position for the spawnlocation
Angle = ASpawnLocationsMafia[Index][SpawnAngle]; // Get the rotation-angle for the spawnlocation
format(Msg, 128, "{00FF00}Le joueur {FFFF00}%s{00FF00} a rejoint {FFFF00}la mafia", Name);
}
else
{
// Let the player know he needs 200 scorepoints
GameTextForPlayer(playerid, "Vous n'кtes pas autorisй a rejoindre cette classe.", 5000, 4);
SendClientMessage(playerid, 0xFFFFFFFF, "{FF0000}Cette classe est rйservй a la faction Mafia.");
return 0;
}
}
}
// Spawn the player with his chosen skin at a random location based on his class
SetSpawnInfo(playerid, 0, GetPlayerSkin(playerid), x, y, z, Angle, 0, 0, 0, 0, 0, 0);
x = ASpawnLocationsPolice[Index][SpawnX]; // Get the X-position for the spawnlocation y = ASpawnLocationsPolice[Index][SpawnY]; // Get the Y-position for the spawnlocation z = ASpawnLocationsPolice[Index][SpawnZ]; // Get the Z-position for the spawnlocation Angle = ASpawnLocationsPolice[Index][SpawnAngle]; // Get the rotation-angle for the spawnlocation |
SetPlayerPos(playerid, ASpawnLocationsPolice[Index][0], ASpawnLocationsPolice[Index][1], ASpawnLocationsPolice[Index][2]); SetPlayerFacingAngle(playerid, ASpawnLocationsPolice[Index][3]); |
CanSpawnAsCop
Factions[APlayerData[playerid][Team]][Type]
new Float: X, Float: Y, Float: Z, Float: Ang;
Factions[APlayerData[playerid][Team]][Type] == 2 |
I'm pretty sure a run time error would cause the script not working correctly (which is your case).
Specifically, in this line: pawn Код:
Load crashdetect plugin (https://github.com/Zeex/samp-plugin-...etect/releases) and compile with -d3 flag: https://github.com/Zeex/samp-plugin-...ith-debug-info Re-compile the script, run the server and try again. Post the server log if you get any output with [debug] prefix. |