Class Selection problem
#1

Hi, i'am scripting a system and i have a small problem , when the player choose this ClassPolice or ClassMafia he will spawn at locations 0.0 0.0 0.0
PHP код:
        case ClassPolice:
        {
            
// Count the number of normal players (all classes except police) and count the amount of police players
            
new NormalPlayersPolicePlayersbool: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 pidpid MAX_PLAYERSpid++)
                {
                    
// 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 
ClassTruckDriverClassBusDriverClassPilotClassMafiaClassCourierClassRoadWorkerClassMarinClassTrainClassPizzaClassAssistanceClassTaxiClassBucheron:
                                        
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 || APlayerData[playerid][PlayerLevel] == || strcmp("trucking"APlayerData[playerid][PlayerName], true24) == 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"50004);
                    
SendClientMessage(playerid0xFFFFFFFF"{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"50004);
                    
SendClientMessage(playerid0xFFFFFFFF"{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));
                
ASpawnLocationsPolice[Index][SpawnX]; // Get the X-position for the spawnlocation
                
ASpawnLocationsPolice[Index][SpawnY]; // Get the Y-position for the spawnlocation
                
ASpawnLocationsPolice[Index][SpawnZ]; // Get the Z-position for the spawnlocation
                
Angle ASpawnLocationsPolice[Index][SpawnAngle]; // Get the rotation-angle for the spawnlocation
                
format(Msg128"{00FF00}Le joueur {FFFF00}%s{00FF00} a rejoint {FFFF00}la police"Name);
            }
            else {
                
GameTextForPlayer(playerid"Vous n'etes pas autorises"50004);
                
SendClientMessage(playerid0xFFFFFFFF"{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));
                
ASpawnLocationsMafia[Index][SpawnX]; // Get the X-position for the spawnlocation
                
ASpawnLocationsMafia[Index][SpawnY]; // Get the Y-position for the spawnlocation
                
ASpawnLocationsMafia[Index][SpawnZ]; // Get the Z-position for the spawnlocation
                
Angle ASpawnLocationsMafia[Index][SpawnAngle]; // Get the rotation-angle for the spawnlocation
                
format(Msg128"{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."50004);
                
SendClientMessage(playerid0xFFFFFFFF"{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(playerid0GetPlayerSkin(playerid), xyzAngle000000); 
Reply
#2

try to add setplayerpos in it
Reply
#3

i have try that, but also this message " format(Msg, 128, "{00FF00}Le joueur {FFFF00}%s{00FF00} a rejoint {FFFF00}la police", Name);" dosn't appear.
Reply
#4

try to change this
Quote:

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

with this
Quote:

SetPlayerPos(playerid, ASpawnLocationsPolice[Index][0], ASpawnLocationsPolice[Index][1], ASpawnLocationsPolice[Index][2]);
SetPlayerFacingAngle(playerid, ASpawnLocationsPolice[Index][3]);

Reply
#5

Код:
CanSpawnAsCop
Check this stock. Maybe this stock is empty . There should have a spawn location
Reply
#6

I'm pretty sure a run time error would cause the script not working correctly (which is your case).

Specifically, in this line:
pawn Код:
Factions[APlayerData[playerid][Team]][Type]
if the value of APlayerData[playerid][Team] is out of bounds (0 to size of Factions-1).

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.
Reply
#7

Did you use Float for cord variables ?
like:
Код:
new Float: X, Float: Y, Float: Z, Float: Ang;
Reply
#8

Yes i use it, Bump i have already this problem , it's come from this :

Quote:

Factions[APlayerData[playerid][Team]][Type] == 2

Reply
#9

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
I'm pretty sure a run time error would cause the script not working correctly (which is your case).

Specifically, in this line:
pawn Код:
Factions[APlayerData[playerid][Team]][Type]
if the value of APlayerData[playerid][Team] is out of bounds (0 to size of Factions-1).

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.
Yes i got an error on this line.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)