Problem with visibility of classes (y_classes and y_groups)
#1

Bumped into many problems on the SA:MP forum, yet, none mentions the problem I am having.

I set up two groups: Citizens and Police. I added 3 skins for the citizens group and 5 for the police group. I set the player's group after his data has loaded. Yet, all the skins are visible for the player.

This is how my code looks like:

OnGameModeInit:
PHP код:
Class_AddForGroup(g_Police3091533.5762, -1675.477413.382889.75790000); // (7)
// I also tried Class_AddEx 
OnPlayerRequestClass:
PHP код:
    switch(classid)
    {
        case 
0..2:
        {
            
// Code
        
}
        case 
3..7:
        {
            
// Code    
        
}
    } 
OnPlayerRequestSpawnEx (y_classes callback):
PHP код:
// Has the same structure of that of OnPlayerRequestClass 
OnPlayerLoad (Custom callback; when the player's data is being loaded)
PHP код:
    Group_SetPlayer(g_Policeplayeridfalse); 
Help is much appreciated.
Reply
#2

Bump, bump. Just kidding; double post to update the situation.

I added debug prints, and figured that the player's group is not being set at all.

When the player's data is being loaded:
PHP код:
    printf("Group setting for %d"playerid);
    
Group_SetPlayer(g_Policeplayeridfalse);
    
printf("Group for %d set."playerid);
    if(
Group_GetPlayer(g_Policeplayerid))
    {
        
printf("%s (%d) is in the police group"returnName(playerid), playerid);
    }
    if(
Group_GetPlayer(g_Citizensplayerid))
    {
        
printf("%s (%d) is in the citizens group"returnName(playerid), playerid);
    } 
Console:
Код:
Group setting for 0
Group for 0 set.
If any of you have an updated version of this, I'll be more than glad to receive the link.

NVM, it is being set (I noticed I set g_police to false). Though, all skins are still visible even for those that are not in the group.
Reply
#3

Group_SetPlayer(g_Police, playerid, false) for all players that are not supposed to be in the group.


ALSO: Use Class_AddWithGroupSet.

ALSO: Even so after that, I recommend using Class_SetPlayer along with that. For example:
Код:
onscriptinit...
Class1 = Class_AddWithGroupSet...//COP SKIN
Class2 = Class_AddWithGroupSet...//COP SKIN
Class3 = Class_AddWithGroupSet...//THUG SKIN
Class4 = Class_AddWithGroupSet...//THUG SKIN

onplayer...
//set all classes to false
Class_SetPlayer(Class1, playerid, false)
Class_SetPlayer(Class2, playerid, false)
Class_SetPlayer(Class3, playerid, false)
Class_SetPlayer(Class4, playerid, false)

if(player is in cop group?)
Class_SetPlayer(Class1, playerid, true)
Class_SetPlayer(Class2, playerid, true)
if(player is in thug group?)
Class_SetPlayer(Class3, playerid, true)
Class_SetPlayer(Class4, playerid, true)
Reply
#4

LAST EDIT: It works. I am very, very careless. Instead of setting all classes to false under OnPlayerConnect, I had set them all to true. Stupid, stupid, stupid. Thank you Crayder for your assistance.

Doesn't work, Crayder.

I used Class_AddWithGroupSet instead of Class_AddForGroup.
I reset the visibility of each class when the player connects.
I set his group to g_Citizens when his data has been loaded.
I set the visibility of the citizen classes to true for that player and leave the police classes invisible.
I then toggle the player's spectating to false to let him see the class selection (I also tried "Class_ReturnToSelection(playerid);").

EDIT: tried using Class_DenySelection instead of Toggling the player's spectating. Got an "undefined symbol" error for Class_DenySelection. Took a look into the includes, the function didn't exist.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)