AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Flags question.... (https://forums.alliedmods.net/showthread.php?t=17834)

Batman/Gorlag 09-10-2005 04:05

Flags question....
 
Alright just one question, if you set the player flag, meaning you, from FL_ONGROUND to FL_SWIM, and then you started moving, would you be moving as if you were swimming?

P.S. Alright if you registered a cvar, where would you paste the cvar information? In amxx.cfg?

p3tsin 09-10-2005 07:05

1) i dont think so, only if the player is not touching the ground

2) huh?
Code:
native register_cvar(const name[],const string[],flags = 0,Float:fvalue = 0.0);

Zenith77 09-10-2005 11:21

1) Yes it would you move as you were swimming..

2) You could post the cvar anywhere a file was executed( well not anywhere) either amxx.cfg or server.cfg, or you could create your own .cfg and tell the plugin to execute it....

Batman/Gorlag 09-10-2005 15:18

Hmm....okay one more question, if you also set the flag to FL_INWATER could you move up and down as if you were in water?

XxAvalanchexX 09-10-2005 15:44

pm_shared.c handles your movement if I'm not mistaken, and it doesn't use FL_INWATER at all. It uses waterlevel and watertype. Also, in certain parts it uses PointContents to see if you're in water. Your best bet is to try this every prethink or postthink (I'm not sure which):

Code:
entity_set_int(id,EV_INT_waterlevel,3); // fully submerged entity_set_int(id,EV_INT_watertype,CONTENTS_WATER); // I'm in water, not acid or something

NOTE: This may make you drown.

Batman/Gorlag 09-10-2005 17:50

Oh really, cause I thought I would have to rewrite the whole movement functions if you moved in the air....Here's my coding so far. BTW: My left and right button doesn't work. And you can ignore the whole movetype fly stuff as well, I didn't bother erasing it yet that's why it's still there lol.

EDIT: I changed the buttons to moveleft and moveright, I'm gonna see if this works now....

Code:
public client_PreThink(id) {     new Float:maxSpeed = 1000, Float:walkSpeed = 350     new Float:fVelocity[3], Float:v_angles[3]     new flag = entity_get_int(id, EV_INT_flags)     if(isFlyModeEnabled == true && is_user_alive(id)){         if(get_user_button(id) == IN_JUMP){             if(flag & FL_ONGROUND){                 entity_set_int(id, EV_INT_flags, FL_INWATER)             }         }         if(!(flag & FL_ONGROUND)){                          if(get_user_button(id) == IN_FORWARD){                 velocity_by_aim(id, maxSpeed, fVelocity)                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             if(get_user_button(id) == IN_BACK){                 velocity_by_aim(id, maxSpeed, fVelocity)                 fVelocity[0] -= fVelocity[0]*2.0                 fVelocity[1] -= fVelocity[1]*2.0                 fVelocity[2] -= fVelocity[2]*2.0                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             if(get_user_button(id) == IN_LEFT){                 entity_get_vector(id, EV_VEC_v_angle, v_angles)                 v_angles[0] += 90.0                 v_angles[1] += 90.0                 fVelocity[0] = floatcos(v_angles[1], degrees) * maxSpeed                 fVelocity[1] = floatsin(v_angles[1], degrees) * maxSpeed                 fVelocity[2] = 0.0                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             if(get_user_button(id) == IN_RIGHT){                 entity_get_vector(id, EV_VEC_v_angle, v_angles)                 v_angles[0] += 270.0                 v_angles[1] += 270.0                 fVelocity[0] = floatcos(v_angles[1], degrees) * maxSpeed                 fVelocity[1] = floatsin(v_angles[1], degrees) * maxSpeed                 fVelocity[2] = 0.0                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             if(flag & FL_FLY){                 client_print(0, print_chat, "You are flying!")             }             else if(flag & FL_SWIM){                 client_print(0, print_chat, "You are swimming!")             }             else{                 client_print(0, print_chat, "You are doing something else!")             }         }         if(flag & FL_ONGROUND){             if(flag & FL_INWATER){                 entity_set_int(id, EV_INT_movetype, MOVETYPE_WALK)                 set_user_maxspeed(id, walkSpeed)             }         }     }     if(!isFlyModeEnabled && is_user_alive(id)){         if(entity_get_int(id, EV_INT_movetype) == MOVETYPE_FLY){             entity_set_int(id, EV_INT_movetype, MOVETYPE_WALK)             set_user_maxspeed(id, walkSpeed)         }     }     //entity_set_float(id, EV_FL_nextthink, 0.001) }

Now my question is, if I implement your code, I wouldn't have to mess around with the movement buttons right (like what you see above)?

XxAvalanchexX 09-10-2005 20:35

I don't know, I've never tried.

Batman/Gorlag 09-11-2005 02:27

Okay, well I tested out my prethink method, and I can go forwards or backwards in the air, but I can't seem to move left or right. I was wondering if there was something wrong with my coding and also if I push any other buttons like the attack button, I just stand still could someone help me out on this:

Code:
public client_PreThink(id) {     new Float:maxSpeed = 1000     new Float:fVelocity[3], Float:v_angles[3]     new flag = entity_get_int(id, EV_INT_flags)     if(isFlyModeEnabled && is_user_alive(id)){         if(!(flag & FL_ONGROUND)){                          if(get_user_button(id) == IN_FORWARD){                 velocity_by_aim(id, maxSpeed, fVelocity)                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             else if(get_user_button(id) == IN_BACK){                 velocity_by_aim(id, maxSpeed, fVelocity)                 fVelocity[0] -= fVelocity[0]*2.0                 fVelocity[1] -= fVelocity[1]*2.0                 fVelocity[2] -= fVelocity[2]*2.0                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             else if(get_user_oldbutton(id) == IN_FORWARD && get_user_button(id) == IN_ATTACK){                 velocity_by_aim(id, maxSpeed, fVelocity)                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             else if(get_user_oldbutton(id) == IN_FORWARD && get_user_button(id) == IN_ATTACK2){                 velocity_by_aim(id, maxSpeed, fVelocity)                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             else if(get_user_oldbutton(id) == IN_BACK && get_user_button(id) == IN_ATTACK){                 velocity_by_aim(id, maxSpeed, fVelocity)                 fVelocity[0] -= fVelocity[0]*2.0                 fVelocity[1] -= fVelocity[1]*2.0                 fVelocity[2] -= fVelocity[2]*2.0                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             else if(get_user_oldbutton(id) == IN_BACK && get_user_button(id) == IN_ATTACK2){                 velocity_by_aim(id, maxSpeed, fVelocity)                 fVelocity[0] -= fVelocity[0]*2.0                 fVelocity[1] -= fVelocity[1]*2.0                 fVelocity[2] -= fVelocity[2]*2.0                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             else if(get_user_button(id) == IN_MOVELEFT){                 entity_get_vector(id, EV_VEC_v_angle, v_angles)                 v_angles[0] += 90.0                 v_angles[1] += 90.0                 fVelocity[0] = floatcos(v_angles[1], degrees) * maxSpeed                 fVelocity[1] = floatsin(v_angles[1], degrees) * maxSpeed                 fVelocity[2] = floatsin(-v_angles[0], degrees) * maxSpeed                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             else if(get_user_button(id) == IN_MOVERIGHT){                 entity_get_vector(id, EV_VEC_v_angle, v_angles)                 v_angles[0] += 270.0                 v_angles[1] += 270.0                 fVelocity[0] = floatcos(v_angles[1], degrees) * maxSpeed                 fVelocity[1] = floatsin(v_angles[1], degrees) * maxSpeed                 fVelocity[2] = floatsin(-v_angles[0], degrees) * maxSpeed                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }             else{                 fVelocity[0] = 0.0                 fVelocity[1] = 0.0                 fVelocity[2] = 1.0                 entity_set_vector(id, EV_VEC_velocity, fVelocity)             }         }     } }

Freecode 09-11-2005 02:49

i thin its IN_LEFT/RIGHT but might be wrong

Batman/Gorlag 09-11-2005 02:52

Actually I have tried LEFT and RIGHT and it didn't work, the LEFT and RIGHT button I found out was just for turning, MOVELEFT and MOVERIGHT is what actually makes you move left and right. And I gave more info in my previous post, cause I'm thinking it's that else statement that's causing me to stand still if I fire a weapon. I'm not sure though...

EDIT: ALright I'm feeling proud of myself, no one helped me on this, but I fixed the whole firing weapon part while not moving in the air, so you can move again. Took a while for me to figure out though. Now all I got to worry about is the left and right operations.


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

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