Closed Jameskmonger closed 11 years ago
Did you initialize the groups? I.e. this.GROUP_CIVILIAN = Group_Create("...");
. Either you do that, or you create static groups, which I think was what you were trying to do.
To create static groups, your definitions would look like this:
new StaticGroup<this.GROUP_CIVILIAN> = "Civilian";
new StaticGroup<this.GROUP_POLICE> = "Po po";
new StaticGroup<this.GROUP_MEDIC> = @"Medic";
I don't recommend prefixing those groups with this.
, though, as I'm assuming other modules won't have their own GROUP_CIVILIAN, etc.
I put this code in header.inc:
new StaticGroup<GROUP_CIVILIAN>; new StaticGroup<GROUP_POLICE>; new StaticGroup<GROUP_MEDIC>;
And now get these errors:
gamemodes/modules/JKM/Class/header.inc(12) : error 021: symbol already defined:
"StaticGroup"
gamemodes/modules/JKM/Class/header.inc(13) : error 021: symbol already defined:
"StaticGroup"
gamemodes/modules/JKM/Class/header.inc(14) : error 021: symbol already defined:
"StaticGroup"
gamemodes/modules/JKM/Class/callbacks/OnGameModeInit.inc(10) : error 017: undefi
ned symbol "GROUP_CIVILIAN"
gamemodes/modules/JKM/Class/callbacks/OnGameModeInit.inc(11) : error 017: undefi
ned symbol "GROUP_POLICE"
gamemodes/modules/JKM/Class/callbacks/OnGameModeInit.inc(12) : error 017: undefi
ned symbol "GROUP_MEDIC"
gamemodes/modules/JKM/Class/callbacks/OnGameModeInit.inc(82) : error 017: undefi
ned symbol "GROUP_CIVILIAN"
gamemodes/modules/JKM/Class/callbacks/OnGameModeInit.inc(87) : error 017: undefi
ned symbol "GROUP_POLICE"
gamemodes/modules/JKM/Class/callbacks/OnGameModeInit.inc(88) : error 017: undefi
ned symbol "GROUP_POLICE"
gamemodes/modules/JKM/Class/callbacks/OnGameModeInit.inc(89) : error 017: undefi
ned symbol "GROUP_POLICE"
gamemodes/modules/JKM/Class/callbacks/OnGameModeInit.inc(93) : error 017: undefi
ned symbol "GROUP_MEDIC"
gamemodes/modules/JKM/Class/callbacks/OnPlayerRequestClass.inc(15) : error 017:
undefined symbol "GROUP_CIVILIAN"
gamemodes/modules/JKM/Class/callbacks/OnPlayerRequestClass.inc(16) : error 017:
undefined symbol "GROUP_POLICE"
gamemodes/modules/JKM/Class/callbacks/OnPlayerRequestClass.inc(17) : error 017:
undefined symbol "GROUP_MEDIC"
gamemodes/modules/JKM/Class/callbacks/OnPlayerSpawn.inc(14) : error 017: undefin
ed symbol "GROUP_CIVILIAN"
gamemodes/modules/JKM/Class/callbacks/OnPlayerSpawn.inc(15) : error 017: undefin
ed symbol "GROUP_POLICE"
gamemodes/modules/JKM/Class/callbacks/OnPlayerSpawn.inc(16) : error 017: undefin
ed symbol "GROUP_MEDIC"
main.pwn(1522) : warning 203: symbol is never used: "StaticGroup"
main.pwn(1522) : warning 203: symbol is never used: "StaticGroup"
main.pwn(1522) : warning 203: symbol is never used: "StaticGroup"
main.pwn(1522) : warning 203: symbol is never used: "StaticGroup"
main.pwn(1522) : warning 203: symbol is never used: "StaticGroup"
main.pwn(1522) : warning 203: symbol is never used: "StaticGroup"
Sorry, I forgot to mention you must provide group names. My first reply is updated.
Fixed this by changing my definitions to this:
new StaticGroup<GROUP_CIVILIAN> = "Civilians"; new StaticGroup<GROUP_POLICE> = "Police"; new StaticGroup<GROUP_MEDIC> = "Medics";
Thanks for the help :)
BTW, use three backtics (```
) instead of the <code>
tag to avoid angle brackets getting stripped.
I am trying to, on spawn, check if the player's class' group if equal to a certain group, in an if-statement. However, it doesn't work. Here are the group declarations in header.inc:
new Group:this.GROUP_CIVILIAN; new Group:this.GROUP_POLICE; new Group:this.GROUP_MEDIC;
Here are the classes' creation lines in OnGameModeInit.inc:
CreateClass(temp_SkinID, civilian_spawn, civilian_weapons, 0, GROUP_CIVILIAN); CreateClass(280, police_spawn, police_weapons_general, 0, GROUP_POLICE); CreateClass(274, medic_spawn, medic_weapons, 0, GROUP_MEDIC);
As you can see, each class is given a different group. However, when I check this in OnPlayerRequestClass or OnPlayerSpawn, nothing happens. For example, when I go to the Medic class on the select class screen, the word "Civilian" is displayed. My code from OnPlayerRequestClass is below:
new class = ClassSelection.RequestedClass[playerid]; // Declare the class variable (makes the if-elseif-else statement below shorter) new this.className[13]; // Declare the className variable that will be used below. if(ClassSelection.Classes[class][Group] == GROUP_CIVILIAN) this.className = "~w~Civilians"; // If a civilian, set the className string to "~w~Civilians" else if(ClassSelection.Classes[class][Group] == GROUP_POLICE) this.className = "~b~Police"; // If a police officer, set the className string to "~b~Police" else if(ClassSelection.Classes[class][Group] == GROUP_MEDIC) this.className = "~g~Medics"; // If a medics, set the className string to "~g~Medics" else this.className = " "; // If none of the above are true (something's wrong) then just set the class name to a space, effectively blank GameTextForPlayer(playerid, this.className, 1000, 4); // Show a second-long gametext to the player, containing the name of their "team" (group)
Furthermore, when I spawn as either a policeman or a medic, my colour is still white (as the civilian class). The code from OnPlayerSpawn is below:
new class = ClassSelection.PlayerClass[playerid]; // Declare the class variable (makes the if-elseif-else statement below shorter) if(ClassSelection.Classes[class][Group] == GROUP_CIVILIAN) SetPlayerColor(playerid, COLOUR_WHITE); // If a civilian, set player to the civilian colour (white) else if(ClassSelection.Classes[class][Group] == GROUP_POLICE) SetPlayerColor(playerid, COLOUR_POLICEBLUE); // If a police officer, set player to the police colour (policeblue) else if(ClassSelection.Classes[class][Group] == GROUP_MEDIC) SetPlayerColor(playerid, COLOUR_MEDICGREEN); // If a medic, set player to the medic colour (medicgreen)