AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   first script in ages 4 errors left (https://forums.alliedmods.net/showthread.php?t=2442)

ErUs 06-05-2004 12:54

first script in ages 4 errors left
 
Code:
#include <amxmodx> #include <cstrike> public getplayor() {   new x = 0   new playaz[64]   for ( x=1; 65; x = (x + 1) ) {     cs_reset_user_model(x);     if (cs_get_user_team(x) == 1) {       playaz[x] = 1     }     else if (cs_get_user_team(x) == 2) {       playaz[x] = 2     }     else playaz[x] = 0   } changeth(x) } public changeth(x) {        while( x < 65 ) {   x = random_num(1,64)   if (playaz[x] > 0) {     cs_set_user_model( x , "hostage01.mdl");     break     }     } } public plugin_init() {   register_plugin("Tomsmod","0.01","TOM aka ErUs")   register_event("ResetHUD", "getplayor", "be") }

Theres probly something i done stupidly wrplz correct for me
:( [/code]

Mugwump 06-05-2004 14:12

Did you intend for the condition portion of your loop to be just 65? Or did you mean something like this:

(for new x=1; x<65; x=x+1)

? I don't think you have a stopping condition in your loop, so I would revise that ...

Also, is it complaining about loose indentation, or is that just an effect from posting it here, as the indentation could cause problems if the indentation of the code doesn't follow the intended logic flow ...

Please post the error messages, that would help.

Mugwump

karlos 06-05-2004 14:22

change
"for ( x=1; 65; x = (x + 1) ) {"
to
"for ( x=1; x<=65; ++x) {"
and make
new playaz[64] a global variable

also playaz[64] dont need to be 64 cause there are only max 32 players
it should be changed to 33 and therefore also 65 to 32 at "for ( x=1; x<=65; ++x) {"
it should not be
Code:
   }     else playaz[x] = 0   } changeth(x) }
but
Code:
   }     else playaz[x] = 0   }   changeth(x) }
look at the position of changeth(x)

dont really understand what your plugin should do?

ErUs 06-05-2004 14:31

its ment to change a random players model at the start of each round

[FBX] 06-05-2004 23:17

interesting method, I would have simply used gotten the players, changed one's random model, and just left it at one function... but thats me. You do realize that playaz isnt a global variable and thus the function changeth couldn't possibly know that the two the same. You can either pass playaz to changeth or you could be lazy like the rest of us and make it global (by declaring it outside of a function, at the top of the script).

T(+)rget 06-06-2004 19:12

This part is wrong:
Code:

new playaz[64]
for ( x=1; 65; x = (x + 1) ) {

It should be:
Code:

new playaz[64]
for (x=0; x < 64; x++) {

You can't have your arrays smaller than your range.


All times are GMT -4. The time now is 14:51.

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