AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Non-Moving player (https://forums.alliedmods.net/showthread.php?t=51541)

FormulaZero 02-19-2007 19:17

Non-Moving player
 
How would I get to know if the player is standing still for (x) amount of time and is on the ground? And what would I have to: register_event to

XxAvalanchexX 02-19-2007 19:23

Re: Non-Moving player
 
Code:
 #include <amxmodx>  #include <fakemeta>  new Float:lastMove[33];  public plugin_init()  {     register_forward(FM_PlayerPreThink,"fw_playerprethink",1);  }  public fw_playerprethink(id)  {     static Float:velocity[3];     pev(id,pev_velocity,velocity);     new Float:gtime = get_gametime();     if(velocity[0] || velocity[1] || velocity[2] || !(pev(id,pev_flags) & FL_ONGROUND))         lastMove[id] = gtime;     if(gtime-lastMove[id] >= 5.0)     {         client_print(id,print_chat,"* You haven't moved for five seconds!");         lastMove[id] = gtime;     }     return FMRES_IGNORED;  }

This monitors when they move (have velocity) or get off the ground (FL_ONGROUND is not a part of their entity flags). Then, it records that time. It also checks to see if it's been 5.0 seconds since the last recorded time that they moved.

You'll probably want to not check this on death, and also reset the lastMove time on spawn.

FormulaZero 02-19-2007 19:29

Re: Non-Moving player
 
So, this would moniter when they are not moving 'camping' this isn't going to be the full code though. ;)

Code:
 #include <amxmodx>  #include <fakemeta>    #define PLUGIN "Punish The Camper"  #define VERSION "1.0"  #define AUTHOR "FormulaZero"  new Float:lastMove[33];  public plugin_init()  {     register_forward(FM_PlayerPreThink,"fw_playerprethink",1)  }  public fw_playerprethink(id)  {     static Float:velocity[3]     pev(id,pev_velocity,velocity)     new Float:time = get_gametime()     if(velocity[1] || velocity[0] || velocity[2] || !(pev(id,pev_frags) & FL_OFFGROUND))         lastMove[id] = time     if(time-lastMove[id] >= 10.7)     {         client_print(id,print_chat,"[*]You havn't moved for 11 seconds, you will now be punished")         lastMove[id] = time     }     return FMRES_IGNORED  }


Da_sk8rboy 02-19-2007 19:34

Re: Non-Moving player
 
post in small tags..

FormulaZero 02-19-2007 19:36

Re: Non-Moving player
 
I have edited it.

XxAvalanchexX 02-19-2007 19:44

Re: Non-Moving player
 
Probably. But there is no FL_OFFGROUND, only FL_ONGROUND (which is why I use !, for NOT).

FormulaZero 02-19-2007 19:48

Re: Non-Moving player
 
Ah, okay.

SpikeyHair 02-21-2007 07:53

Re: Non-Moving player
 
Quote:

Originally Posted by XxAvalanchexX (Post 442692)
Probably. But there is no FL_OFFGROUND, only FL_ONGROUND (which is why I use !, for NOT).

Thank you Avalanche this helped me to. good luck formula


All times are GMT -4. The time now is 07:56.

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