AlliedModders

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

Obbin 08-26-2005 15:30

aimkill
 
how do i make an function that kills a player if <playerid> aims at him, but onley if <playerid> is in an radius of let's say 10meters from him?
I allso wanna know how to use get_cvar_num()! (make the value of mp_freesetime a variable)

hope you understood!

Twilight Suzuka 08-26-2005 15:42

Code:


public kill_user_aiming(id)
{
        new tid, body;
        get_user_aiming(id,tid,body,100)

        if(is_valid_ent(tid) && tid <= get_maxplayers() ) user_kill(tid,1);
}

Code:

new cvar_value = get_cvar_num("cvarname")

Obbin 08-27-2005 05:17

how would i do if the user that <someone> is aiming @ onley gets killed if <someone> and <someone #2> is closer then 10 meters from eatchother?

v3x 08-27-2005 05:28

Code:
public RawrKill(id) {     new tid,body;     get_user_aiming(id,tid,body,9999);     if(is_user_alive(id) && is_user_alive(tid))     {         new distance = floatround(entity_range(id,tid));         if(floatround(distance/32.00) <= 10)             user_kill(tid,1);     } }
Tis how I would do it. :)

Obbin 08-27-2005 06:57

Thx, v3x and twlight! :lol:

Twilight Suzuka 08-27-2005 15:22

Quote:

Originally Posted by v3x
Code:
public RawrKill(id) {     new tid,body;     get_user_aiming(id,tid,body,9999);     if(is_user_alive(id) && is_user_alive(tid))     {         new distance = floatround(entity_range(id,tid));         if(floatround(distance/32.00) <= 10)             user_kill(tid,1);     } }
Tis how I would do it. :)

First off, 10 isn't ten meters. Ten is ten units, IE, ten inches or so.

Second, why not handle it completely in the engine, by simply making get_user_aiming do the work? It can't capture people that are not alive, and the last parameter is how far they are from one another.

Thats just wasting CPU.

XxAvalanchexX 08-27-2005 15:56

Quote:

Originally Posted by Twilight Suzuka
the last parameter is how far they are from one another.

The last parameter is the distance get_user_aiming is allowed to check, the actual distance between them is returned by the native.

Twilight Suzuka 08-27-2005 16:09

Exactly. So if you want it below ten meters, you set it to about 100, and it'll check to see if their within that radius.

12 * 3 * 3 = 108, 100 being a good approximate distance.

Obbin 08-27-2005 16:36

uh.. any example twlight or avalanche?
(i readed at funcwiki.php but i didn't undrestand)

Xanimos 08-27-2005 17:48

If im reading what twilight and ava have said:
Code:
public DieDamnit(id) {     new tid,body;     new distance = get_user_aiming(id,tid,body,100);   //change last number there to go farther     if(is_user_alive(tid))         user_kill(tid , 1); }

[EDIT] Fixed


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

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