AlliedModders

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

bwgrubbs1 06-19-2007 14:50

set_pev ?
 
I have this code for a new entity that i am touching that will give you low gravity for 4 seconds and execute jump.

My way of thinking is that this would work..but it seems not to.

Here is what I have ...

Code:
public fwdTouch(ent, id) {     (...)     else if(equali(szClassname, "lowgrav"))     {         set_pev(id,pev_gravity,200);         client_cmd(id, "+jump");         set_task(4.0,"normal_grav");         return PLUGIN_HANDLED_MAIN;     } return PLUGIN_HANDLED_MAIN; }

Code:
public normal_grav(id) {     set_pev(id,pev_gravity,800);     client_cmd(id, "-jump"); }

The problems I am having are when you touch entity it gives you low gravity, but i think it starts out around 200 then goes to 0 or a neg value...cuz you never come down. Then on new round you can't jump...which i think is because your gravity is still set too low.

Anyone...lol ?

Emp` 06-19-2007 15:24

Re: set_pev ?
 
First off, pev_gravity needs a float.

Second, I could be wrong, but I think pev_gravity is based on a 1.0 scale. (1.0 being normal grav)

And why not just use fun?

Greenberet 06-19-2007 15:25

Re: set_pev ?
 
you dont send the client id through set_task

Zenith77 06-19-2007 17:10

Re: set_pev ?
 
As Emp` pointed out, pev_gravity from what I've seen is just a scale based on sv_gravity. For example, if the server gravity were to be 800 and an entity/player's pev_gravity would be 1 they would act according to the server's gravity value of 800. However, if you had pev_gravity set to 0.5 that would be half of the server gravity or 2 for double.

bwgrubbs1 06-19-2007 20:42

Re: set_pev ?
 
Well, thank you for all your input, and ...

Quote:

Originally Posted by Emp` (Post 492008)
And why not just use fun?

i just like using the pev's i think its funner and i dont wanna include fun also...

Quote:

Originally Posted by Greenberet (Post 492008)
you dont send the client id through set_task

What do you mean by this ?

Quote:

Originally Posted by Emp` (Post 492008)
I could be wrong, but I think pev_gravity is based on a 1.0 scale.

I will try this out...THANKS

kmal2t 06-20-2007 03:22

Re: set_pev ?
 
just use an if(!(pev(id, pev_flags) & FL_ONGROUND)) with a bool in a prethink that goes to a function that then turns off the bool and has a 4 sec set task to your grav with the bool resetting once on ground.

Greenberet 06-20-2007 04:28

Re: set_pev ?
 
Code:
set_task(4.0,"normal_grav")

you dont give the client id to set_task, so you wont get it in normal_grav when you call it.

Code:
new CORE[1]; CORE[0] = id; set_task(4.0,"normal_grav",_, CORE, 1 );

and then you have to read the id in the normal_grav function
Code:
public normal_grav(CORE[]) {      new id = CORE[0];      set_pev(id,pev_gravity,800);      client_cmd(id, "-jump"); }

Alka 06-20-2007 11:06

Re: set_pev ?
 
Hum...i have a question! I have those functions :

Code:

public func_call(id)
{
 new parm[1]
 parm[0] = id
 
 set_task(1.0,"_health",_, parm, 1, "b")
}
 
public _health(parm[])
{
 new id = parm[0]
 
 if(!pev_valid(id))
  return 1;
 
 static health = pev(id,pev_health)
 
 if(health >= 100)
  remove_task(id)
 
 set_pev(id,pev_health, health + 2)
}

When health is > or = should remove the task,but is not removed!How i remove task in this case?

bwgrubbs1 06-20-2007 11:16

Re: set_pev ?
 
Quote:

Originally Posted by kmal2t (Post 492224)
just use an if(!(pev(id, pev_flags) & FL_ONGROUND)) with a bool in a prethink that goes to a function that then turns off the bool and has a 4 sec set task to your grav with the bool resetting once on ground.

Could you explain this to me a bit more...if I semi-understand you...I should change the way that i have this coded to...

Code:
new bool:haslowgrav[33]; public client_PreThink(id) {     if(haslowgrav[id])     {           if(FL_ONGROUND);           set_pev(id,pev_gravity,1.0);     }     return PLUGIN_CONTINUE; } public fwdTouch(ent, id) {     static szClassname[33];     pev(ent, pev_classname, szClassname, 32);     (...)     else if(equali(szClassname, "lowgrav"))     {         set_pev(id,pev_gravity,0.20);         client_cmd(id, "+jump");         haslowgrav[id] = true;         return PLUGIN_HANDLED_MAIN;     }     return PLUGIN_HANDLED_MAIN; }

What about something like this...or should i use Post think ?

Zenith77 06-20-2007 11:38

Re: set_pev ?
 
Code:
if(FL_ONGROUND);

This should be:

Code:
if (pev(id, pev_flags) & FL_ONGROUND) {      // code }


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

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