AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Scirpting help..too many errors (https://forums.alliedmods.net/showthread.php?t=17089)

Velocity36 08-25-2005 16:52

Scirpting help..too many errors
 
I'm trying to make a flying plugin where everybody in the server can fly, derived from AssKicR's superhero, supergirl. I get like 20 errors when compiling (SEE POST#7) , can somebody please help me? Thanks.

Code:
#include <amxmodx> #include <engine> #include <fun> new bool:gIsFlying[33] new bool:roundfreeze new Float:gVelocity[36] public plugin_init()     {     register_plugin("I Am Flying!!", "1.0", "Velocity36")     register_cvar("flying_flybeforeftime", "0")     register_cvar("flying_flyspeed", "300")                 register_srvcmd("flying_init", "flying_init")                 register_event("ResetHUD", "newSpawn", "b")             register_logevent("round_start", 2, "1=Round_Start")     register_logevent("round_end", 2, "1=Round_End")     register_logevent("round_end", 2, "1&Restart_Round_")         register_srvcmd("flying_ku", "flying_ku")             register_srvcmd("flying_kd", "flying_kd")     } public flying_init()     {         new temp[6]     read_argv(1,temp,5)     new id = str_to_num(temp)                 if ( !is_user_alive(id) )         {         if ( gIsFlying[id] )             {             stop_fly(id)         }     }         } public newSpawn(id)     {     if( gIsFlying[id] )         {         stop_fly(id)     } } public flying_kd()     {         new temp[6]     read_argv(1, temp, 5)     new id = str_to_num(temp)         if ( !is_user_alive(id) ) return         if ( roundfreeze && get_cvar_num("flying_flybeforeftime") == 0 )         {         client_print(id, print_chat, "[FLYING] You must wait until the round has started to fly")         return     }         make_fly(id) } public flying_ku()     {         new temp[6]     read_argv(1,temp,5)     new id = str_to_num(temp)         if ( !gIsFlying[id] ) return         stop_fly(id) } public round_end()     {     roundfreeze = true     } public round_start()     {     roundfreeze = false } public make_fly(id)     {     if( !is_user_alive(id) || gIsFlying[id] ) return         client_print(id, print_center, "Up, Up and Away! - Flying Mode ON")         set_user_gravity(id, 0.001)         set_task(0.1, "user_fly", id, "", 0, "b")         gIsFlying[id] = true } public stop_fly(id)     {     if ( !gIsFlying[id] ) return         if ( is_user_alive(id) ) client_print(id, print_center, "Flying Mode OFF")         gIsFlying[id] = false         remove_task(id) } public user_fly(id)     {     new Float: xAngles[3]     new Float: xOrigin[3]     new xEnt         if ( !is_user_alive(id) ) {         stop_fly(id)         return PLUGIN_HANDLED     }         new butnprs = entity_get_int(id, EV_INT_button)         if(butnprs&IN_FORWARD && butnprs&IN_MOVERIGHT && butnprs&IN_JUMP)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = -45.0         xAngles[1] -= 45                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(id, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_FORWARD && butnprs&IN_MOVERIGHT && butnprs&IN_DUCK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 45.0         xAngles[1] -= 45                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_FORWARD && butnprs&IN_MOVELEFT && butnprs&IN_JUMP)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = -45.0         xAngles[1] += 45                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_FORWARD && butnprs&IN_MOVELEFT && butnprs&IN_DUCK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 45.0         xAngles[1] += 45                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_JUMP && butnprs&IN_MOVERIGHT && butnprs&IN_BACK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = -45.0         xAngles[1] -= 135                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_BACK && butnprs&IN_MOVERIGHT && butnprs&IN_DUCK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 45.0         xAngles[1] -= 135                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_JUMP && butnprs&IN_MOVELEFT && butnprs&IN_BACK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = -45.0         xAngles[1] += 135                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_BACK && butnprs&IN_MOVELEFT && butnprs&IN_DUCK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 45.0         xAngles[1] += 135                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVERIGHT && butnprs&IN_FORWARD)         {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 0.0         xAngles[1] -= 45                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVERIGHT && butnprs&IN_BACK)         {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 0.0         xAngles[1] -= 135                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVELEFT && butnprs&IN_FORWARD)         {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 0.0         xAngles[1] += 45                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVELEFT && butnprs&IN_BACK)         {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 0.0         xAngles[1] += 135                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_FORWARD && butnprs&IN_JUMP)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = -45.0                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_FORWARD && butnprs&IN_DUCK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 45.0                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_BACK && butnprs&IN_JUMP)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = -45.0         xAngles[1] += 180                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_BACK && butnprs&IN_DUCK)         {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 45.0         xAngles[1] += 180                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVERIGHT && butnprs&IN_JUMP)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = -45.0         xAngles[1] -= 90                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVERIGHT && butnprs&IN_DUCK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 45.0         xAngles[1] -= 90                 entity_set_origin(xEnt, xOrigin)         entity_get_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVELEFT && butnprs&IN_JUMP)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = -45.0         xAngles[1] += 90                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVELEFT && butnprs&IN_DUCK)           {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 45.0         xAngles[1] += 90                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_FORWARD)         {         VelocityByAim(id, get_cvar_num("flying_flyspeed") , gVelocity[id])     }     else if(butnprs&IN_BACK)         {         VelocityByAim(id, -get_cvar_num("flying_flyspeed") , gVelocity[id])     }     else if(butnprs&IN_DUCK)         {         gVelocity[id][0] = 0.0         gVelocity[id][1] = 0.0         gVelocity[id][2] = -get_cvar_num("flying_flyspeed") * 1.0     }     else if(butnprs&IN_JUMP)         {         gVelocity[id][0] = 0.0         gVelocity[id][1] = 0.0         gVelocity[id][2] = get_cvar_num("flying_flyspeed") * 1.0     }     else if(butnprs&IN_MOVERIGHT)         {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 0.0         xAngles[1] -= 90                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else if(butnprs&IN_MOVELEFT)         {         entity_get_vector(id, EV_VEC_v_angle, xAngles)         entity_get_vector(id, EV_VEC_origin, xOrigin)                 xEnt = create_entity("info_target")         if(xEnt == 0) {             return PLUGIN_HANDLED_MAIN         }                 xAngles[0] = 0.0         xAngles[1] += 90                 entity_set_origin(xEnt, xOrigin)         entity_set_vector(xEnt, EV_VEC_v_angle, xAngles)                 VelocityByAim(xEnt, get_cvar_num("flying_flyspeed"), gVelocity[id])                 remove_entity(xEnt)     }     else {         gVelocity[id][0] = 0.0         gVelocity[id][1] = 0.0         gVelocity[id][2] = 0.0     }             entity_set_vector(id, EV_VEC_velocity, gVelocity[id])         new Float: pOrigin[3]     new Float: zOrigin[3]     new Float: zResult[3]         entity_get_vector(id, EV_VEC_origin, pOrigin)         zOrigin[0] = pOrigin[0]     zOrigin[1] = pOrigin[1]     zOrigin[2] = pOrigin[2] - 1000         TraceLn(id,pOrigin, zOrigin, zResult)             if(entity_get_int(id, EV_INT_sequence) != 8 && (zResult[2] + 100) < pOrigin[2] && is_user_alive(id) && (gVelocity[id][0] > 0.0 && gVelocity[id][1] > 0.0 && gVelocity[id][2] > 0.0))         entity_set_int(id, EV_INT_sequence, 8)         return PLUGIN_HANDLED }

Brad 08-25-2005 16:55

You can start by replacing this line:
Code:
register_plugin("I Am Flying!!", "1.0", "Velocity36"
With this one:
Code:
register_plugin("I Am Flying!!", "1.0", "Velocity36")

Next you can reconcile this:
Code:
new bool:gIsFlying
With all occurrences of this:
Code:
if ( gIsFlying[id] )

Then you can add this line:
Code:
#include <fun>

Velocity36 08-25-2005 16:58

+1 for you, quick reply, and thanks for the help, keep going :)


can you explain the reconcile part though?

Brad 08-25-2005 17:00

You defined gIsFlying as a single boolean value, it can contain either true or false. However, when you use it throughout your code, you indicate it's an array of booleans. It can't be both.

Also, a quick note about debugging. If you get a lot of errors, don't be overwhelmed. Just start with the first one (as it probably caused the others) and fix it, then try to recompile. Repeat until a clean compile.

Velocity36 08-25-2005 17:02

oh so how do I turn the single bool to an array?

Brad 08-25-2005 17:05

:lol: You keep replying too fast. Both of my posts, I've gone back and edited to add additional information thinking that I could do so before you read it. I was wrong on both accounts.

I'm a little shaky on boolean arrays but I think you can use code such as:
Code:
new bool:gIsFlying[32]
I hope anyone reading this can either confirm or correct what I have written.

Velocity36 08-25-2005 17:10

Thanks a bundle brad, I'll try that

Velocity36 08-25-2005 18:21

Script updated, and I get these errors. BTW I don't get the array sizes must match when I take off the [36] after gVelocity, but I do get not array or to many subscipts-gVelocity


/home/groups/amxmodx/tmp/phpGG8C9T.sma(158) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(178) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(198) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(218) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(238) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(258) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(278) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(298) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(318) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(338) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(358) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(378) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(398) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(417) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(437) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(457) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(477) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(497) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(517) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(537) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(543) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(547) : error 047: array sizes must match
/home/groups/amxmodx/tmp/phpGG8C9T.sma(551) : warning 215: expression has no effect
/home/groups/amxmodx/tmp/phpGG8C9T.sma(551) : error 001: expected token: ";", but found "["
/home/groups/amxmodx/tmp/phpGG8C9T.sma(551) : error 029: invalid expression, assumed zero
/home/groups/amxmodx/tmp/phpGG8C9T.sma(551) : warning 215: expression has no effect
/home/groups/amxmodx/tmp/phpGG8C9T.sma(551) : error 001: expected token: ";", but found "]"
/home/groups/amxmodx/tmp/phpGG8C9T.sma(551) : fatal error 107: too many error messages on one line

Freecode 08-25-2005 19:15

Code:
new bool:gIsFlying[33]

Brad 08-25-2005 21:31

I was pretty close. Thanks for the correction.


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

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