OnPlayerRequestClass > PROBLEM
#1

https://pastebin.com/sYSTyxKe


I tried everything but It won't work,

I can only choose the Army Fraction, even if I am swat, nothing works
Reply
#2

Your code has error?
Reply
#3

no code is error-free
Reply
#4

You should consider doing it like this
PHP код:
public OnGameModeInit(){
    
AddPlayerClassEx(1, 3, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 6, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 17, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 19, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 21, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 23, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 28, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 29, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 37, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 46, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 49, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 91, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 138, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 140, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(1, 233, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 300, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 301, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 302, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 306, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 307, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 309, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 310, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 283, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(2, 288, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
AddPlayerClassEx(3, 285, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);           
    
AddPlayerClassEx(4, 287, 1275.7145,-790.4781,1089.9375,206.3436, 0, 0, 0, 0, 0, 0);
    
    return 
1;
}
public 
OnPlayerRequestClass(playerid, classid){
    
SetPlayerInterior(playerid,5);
    
SetPlayerPos(playerid,1275.7145,-790.4781,1089.9375);
    
SetPlayerCameraPos(playerid,1277.1993,-793.9561,1089.9375);
    
SetPlayerCameraLookAt(playerid,1275.7145,-790.4781,1089.9375);
    
ApplyAnimation(playerid, "DANCING", "DAN_Left_A", 2.1, 1, 1, 0, 1, 1, 1);
    
SetPlayerFacingAngle(playerid,270.5306);
    
    switch(
classid){
        case 
1:{
            
format(string, sizeof(string), "~y~> ~p~Civilian ~y~<");
            
GameTextForPlayer(playerid,string,3500,6);        
        }
        case 
2:{
            
format(string, sizeof(string), "~b~> ~p~Cops ~b~<");
            
GameTextForPlayer(playerid,string,3500,6);    
        }
        case 
3:{
            
format(string, sizeof(string), "~b~> ~p~SWAT ~b~<");
            
GameTextForPlayer(playerid,string,3500,6);
        }
        case 
4:{
            
format(string, sizeof(string), "~b~> ~p~ARMY ~b~<");
            
GameTextForPlayer(playerid,string,3500,6);
        }
    }
    return 
1;
}
public 
OnPlayerRequestSpawn(playerid){
    new 
x = GetPlayerTeam(playerid);
    if(
PlayerInfo[playerid][FracID] != 3 && x == 3){
        
SendClientMessage(playerid, -1, "You cannot select SWAT team because ............");
        return 
0;
    }    
    if(
PlayerInfo[playerid][FracID] != 4 && x == 4){
        
SendClientMessage(playerid, -1, "You cannot select ARMY team because ............");
        return 
0;
    } 
    return 
1;
} 
I am sure it will work, but you will have to edit gametexts.
You were adding classes everytime a player was in team selection (requesting class).
Reply
#5

thx very much +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)