AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Compiler killer... (https://forums.alliedmods.net/showthread.php?t=55392)

Rolnaaba 05-20-2007 23:07

Compiler killer...
 
1 Attachment(s)
I think I created a compiler killer....
when i try to compile this plugin ii made with amxxpc.exe I get a windows error saying "amxxpc.exe has encountered a problem and needs to close", so i tried the web compiler...it said
Quote:

Originally Posted by Online Compiler
Your plugin failed to compile! Read the errors below:


200372 successful compiles to date.
110503 failed compiles to date.
Old compiler: 101980 compiles before decommission.
This tool by: David "BAILOPAN" Anderson.

As you can see there are no errors listed...what is up with my plugin?
It is attatched below...

pRED* 05-20-2007 23:17

Re: Compiler killer...
 
Althought I doubt it'd help the CurWeapon event only has one 'r'. Not CurrWeapon.

Rolnaaba 05-20-2007 23:20

Re: Compiler killer...
 
my bad typo...still killing compilers lol

teame06 05-21-2007 00:15

Re: Compiler killer...
 
Code:
get_random_weapon() {     new num = random_num(1, 25);     if(get_pcvar_num(pcvar[CDEBUG]) == 1) {         new tmp = get_gametime();         log_amx("[FunMod] Gametime: %i, GetRandomWeapon function called...info: num=%i", tmp, num);     }     switch(num) {         case 1: return "weapon_ak47"         case 2: return "weapon_aug"         case 3: return "weapon_awp"         case 4: return "weapon_deagle"         case 5: return "weapon_elite"         case 6: return "weapon_famas"         case 7: return "weapon_fiveseven"         case 8: return "weapon_g3sg1"         case 9: return "weapon_gali"         case 10: return "weapon_galil"         case 11: return "weapon_glock18"         case 12: return "weapon_m249"         case 13: return "weapon_m3"         case 14: return "weapon_m4a1"         case 15: return "weapon_mac10"         case 16: return "weapon_mp5navy"         case 17: return "weapon_p228"         case 18: return "weapon_p90"         case 19: return "weapon_scout"         case 20: return "weapon_sg550"         case 21: return "weapon_sg552"         case 22: return "weapon_tmp"         case 23: return "weapon_ump45"         case 24: return "weapon_usp"         case 25: return "weapon_xm1014"     } }

It crashing on your string return. I don't think you can do that. Return it byref.

Code:
new Hi[24]; get_random_weapon(Hi, 23); get_random_weapon(Hi[], len) {     //...     case 3:         copy(Hi, len, "weapon_awp");     //... }

Rolnaaba 05-21-2007 14:40

Re: Compiler killer...
 
yup that was the problem, thanks a lot teame06. I had a ton compiler errors in addittion to that but they all fixed now compiles fine :D BAILOPAN should fix that though...instead of craching compiler it should generate an error...

Rolnaaba 05-21-2007 20:58

Re: Compiler killer...
 
Quote:

Originally Posted by Sawce
Public functions cannot return strings. Change the function to a stock and it should compile just fine.
Compiler errors such as this are best handled by CompuPhase, the maintainers of Pawn. You should verify that the crash still occurs in their latest version first, as amxmodx uses an older version, if you want to submit it there.


Zenith77 05-21-2007 21:01

Re: Compiler killer...
 
Quote:

Originally Posted by teame06 (Post 478880)
Code:
new Hi[24]; get_random_weapon(Hi, 23); get_random_weapon(Hi[], len) {     //...     case 3:         copy(Hi, len, "weapon_awp");     //... }

Instead of doing that do something like this (since weaponnames are constant):

Code:
new gWeaponNames[2][] = {      "weapon_m4a1",      "weapon_ak47" }; // get a random weapon (notice we don't have to call a function :]). gWeaponNames[random(2)];

or somthing along those lines.

Rolnaaba 05-21-2007 22:08

Re: Compiler killer...
 
so declare like this:
Code:
new g_WeaponNames[25] {     "weapon_ak47",     "weapon_aug",     "weapon_awp",     "weapon_deagle",     "weapon_elite",     "weapon_famas",     "weapon_fiveseven",     "weapon_g3sg1",     "weapon_gali",     "weapon_galil",     "weapon_glock18",     "weapon_m249",     "weapon_m3",     "weapon_m4a1",     "weapon_mac10",     "weapon_mp5navy",     "weapon_p228",     "weapon_p90",     "weapon_scout",     "weapon_sg550",     "weapon_sg552",     "weapon_tmp",     "weapon_ump45",     "weapon_usp",     "weapon_xm1014" };

but to get random one would I do:
Code:
g_WeaponNames[random_num(1, 25)];
or:
Code:
g_WeaponNames[random_num(0, 24)];

regalis 05-22-2007 02:34

Re: Compiler killer...
 
random(25) should work fine ;)

Alka 05-22-2007 07:51

Re: Compiler killer...
 
no...is
Code:
random(26)
:wink:


All times are GMT -4. The time now is 10:43.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.