Compiler not compiling...
-
Here is a code with apparently no syntax mistake according to a compiler that refuses to compile
Did it happen to you? did you solve it and do you see the same mistake you did in my code? if so you can help me! (p.s, 99% chance it has to do with my changelevel function)#include maps/mp/_utility; #include maps/mp/gametypes/_weapons; main() { SetGametypeSetting("prematchperiod",0); onplayerconnect(); } onplayerconnect(){ for ( ;; ){ level waittill( "connected", player ); player thread unlimitedAmmo(); player thread onplayerspawned(); } } unlimitedAmmo(){ for ( ;; ){ if (self isFiring() && self attackButtonPressed()){ current_weapon = self getCurrentWeapon(); ClipSize = WeaponClipSize(current_weapon); CurrentClip = self GetWeaponAmmoClip(current_weapon); if (CurrentClip < ClipSize){ self setWeaponAmmoClip(current_weapon, ClipSize); }} wait 0.05; } } onplayerspawned() { level endon( "game_ended" ); self endon( "disconnect" ); for(;;) { self waittill( "spawned_player" ); self thread openclassgenerator(); self thread changelevel(); wait 0.05; } } openclassgenerator() { for(;;) { if(self useButtonPressed() && self attackButtonPressed()) { self IPrintLn( "menu is opened: do !dsr !an94 and !msmc in chat text" ); self thread choseClassSet(); } wait 0.3; } } choseClassSet() { i = 1; while ( i == 1 ){ level waittill( "say", message, player, isHidden ); if ( message == "!dsr"){ self TakeAllWeapons(); self GiveWeapon("dsr50_mp+swayreduc+fmj", 0); self GiveWeapon("knife_held_mp", 0); i--; } else if ( message == "!msmc"){ self TakeAllWeapons(); self GiveWeapon("insas_mp+stalker+fastads", 0); self GiveWeapon("knife_held_mp", 0); i--; } else if (message == "!an94") { self TakeAllWeapons(); self GiveWeapon("an94_mp+stalker+reflex+fastads"); self GiveWeapon("knife_held_mp", 0); i--; } else if (message == "!pdw") { self TakeAllWeapons(); self GiveWeapon("pdw57_mp+stalker+fastads"); self GiveWeapon("knife_held_mp", 0); i--; } else if (message == "!mp7") { self TakeAllWeapons(); self GiveWeapon("mp7_mp+stalker+fastads"); self GiveWeapon("knife_held_mp", 0); i--; } else if (message == "!ksg") { self TakeAllWeapons(); self GiveWeapon("ksg_mp+stalker+fastads"); self GiveWeapon("knife_held_mp", 0); i--; } } } changelevel() { while (true) { mapRotate = level waittill( "say", message, player, isHidden); switch(mapRotate) { case !mp_village: SetDvar( "sv_mapRotationCurrent", "mp_village"); break; } } }
-
zFast A couple of mistakes I see. Waittill() doesn't return a value, you can't use operators in a switch statement's case, and you are using a level waittill() in a self thread. I'd recommend using level waittill() in a level thread in main() or init() because currently if you have multiple players joining at once choosing a class its possible one player will pick for the rest of them because the "say" notify triggers for each player who uses it for every "say" waittill.
-
Okay so I tried to figure out another way around.. As you said, it doesn't return a value, but you can get message, just like i did for choseClassSet + no operators inside an if statement
So it was the operator "!", for some reason it doesn't want to compile "!" inside a switch statement's case
changelevel() { while (true) { level waittill( "say", message, player, isHidden); switch(message) { case mp_village: SetDvar( "sv_mapRotationCurrent", "mp_village"); break; } } }
I'll reply later about the fact that I use level waittill() in a self thread, my compiling issue is solved and now i have to try it