AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   changing user velocity (https://forums.alliedmods.net/showthread.php?t=56859)

bwgrubbs1 06-22-2007 14:13

changing user velocity
 
I am looking to change a users velocity if he touches a certain entity and it will boost him forward.

__-```-__
this is normal jump

__---````````````---__
this is boost jump after touch entity

Get the idea ?

I have this already maybe im stupid on my code.

Code:
public plugin_init() {     (...)     register_forward(FM_Touch, "fwdTouch", 0);     register_forward(FM_PlayerPreThink, "client_PreThink");     (...) } public client_PreThink(id) {     if(!is_user_alive(id))         return PLUGIN_CONTINUE;     new flags = pev(id, pev_flags);     if(hasboost[id])     {         if(flags & FL_ONGROUND)         {             set_pev(id,pev_velocity,{0.0, 0.0, 0.0});             hasboost[id] = false;             return PLUGIN_CONTINUE;         }     }     return PLUGIN_CONTINUE; } public fwdTouch(ent, id) {     (...)     new Float:velocity[] = {0.0, 128.0, 0.0};     (...)     else if(equali(szClassname, "booster"))     {         set_pev(id,pev_velocity,velocity);         hasboost[id] = true;         return PLUGIN_HANDLED_MAIN;     }     return PLUGIN_HANDLED_MAIN; }

kmal2t 06-22-2007 19:27

Re: changing user velocity
 
Wtf is that???

use pev_velocity , velocity_by_aim and set_pev

bwgrubbs1 06-23-2007 02:16

Re: changing user velocity
 
what are you talking about ?

allenwr 06-23-2007 02:46

Re: changing user velocity
 
post #2 doesnt know what fakemeta is, and I am not good enough to help you.

bwgrubbs1 06-23-2007 03:16

Re: changing user velocity
 
Now that I look at it...I think he does know what he's talking about...but he just kinda told me to use stuff like i was stupid.

Well in this case I am...because I looked up what he said

velocity_by_aim

but I dont know HOW to use this function. They give an example, but i am still unclear.

Quote:

Originally Posted by tsimscabinet at msn dot com
This native can easily be manually done with more alteration. This is an example of such:
new Float:vAngles[3] // plug in the view angles of the entity
new Float:vReturn[3] // to get out an origin fDistance away
new Float:fDistance = 400.0 // fDistance being the distance from the entity of your choice
entity_get_vector(id,EV_VEC_v_angles,vAngles)
vReturn[0] = floatcos( vAngles[1], degrees ) * fDistance
vReturn[1] = floatsin( vAngles[1], degrees ) * fDistance
vReturn[2] = floatsin( -vAngles[0], degrees ) * fDistance


kmal2t 06-23-2007 13:48

Re: changing user velocity
 
I didn't give a detailed explanation because I made the assumption you AREN'T stupid and could figure out what I meant. This should work for you fine. the *A* means you are going to have to figure out how to classify your entity since it probably wont be func_wall. You have cvars for how fast (speed), how high you want them (speed_height) and how long you want the boost to last (speed_time).
Code:
#include <amxmodx> #include <fakemeta> new bool:touchENT[33], bool:canSpeed[33]; new Float:veloc1[33][3],Float:veloc2[33][3]; public plugin_init() {     register_plugin("Boost", "1.0", "Skittles");     register_forward(FM_PlayerPreThink, "FM_pthink");     register_forward(FM_Touch, "FM_tch");     register_cvar("speed_height", "100.0");     register_cvar("speed", "1000");     register_cvar("speed_time", "1.0"); } public waiter(id) {     touchENT[id] = false;     canSpeed[id] = true;     set_task(get_cvar_float("speed_time"), "speedOFF", id); } public speedOFF(id) {     canSpeed[id] = false; } public FM_pthink(id) {     if(is_user_alive(id) && !is_user_bot(id)) {         if(touchENT[id]) {             waiter(id);         }         if(canSpeed[id]) {             client_cmd(id, "+jump;wait;-jump");             pev(id, pev_velocity, veloc1[id]);             velocity_by_aim(id, get_cvar_num("speed"), veloc2[id]);             veloc2[id][2] = get_cvar_float("speed_height");             set_pev(id, pev_velocity, veloc2[id])         }     } } public FM_tch(id, Touched) {     if(is_user_alive(id)) {         new class1[32];         pev(Touched, pev_classname, class1, 31);         if(equal(class1, "func_wall")) {    //*A*             touchENT[id] = true;         }     } }

If you want the height to just be normal jump height just remove the speed_height cvar in plugin_init and change
Code:

veloc2[id][2] = get_cvar_float("speed_height");
to
Code:

veloc2[id][2] = veloc1[id][2];

bwgrubbs1 06-24-2007 04:27

Re: changing user velocity
 
no errors or anything...but does nothing.

kmal2t 06-24-2007 14:58

Re: changing user velocity
 
Wow I don't even remember posting last night, yet I got one (two?) posts deleted.. strange. Anyway, if it doesn't work its because you hhave to change func_wall to whatever your entitiy is.


All times are GMT -4. The time now is 21:33.

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