AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Feature for a KZ plugin.. Need Help :) (https://forums.alliedmods.net/showthread.php?t=25076)

Johnny Blaze 03-07-2006 11:47

Feature for a KZ plugin.. Need Help :)
 
I help admin a KZ server, and I do updates and changes on the main plugin used, however, one feature I am trying to implement is causing me some trouble (I have no idea where to start ^^)

I wanted to add some code which constantly monitors players positions, and when they get within a certain distance of another player, semiclip is set on them so they can pass through each other, and then when they get out of range, they turn back solid so they can use timers/buttons/doors etc without any hassel.

I had a quick look through the forum and couldnt find much related to this that actually worked, so any help would be appreciated.

I've seen this in use on 3 servers, so its possible, it's just beyond my capabilities :(

Thanks.

Zenith77 03-07-2006 15:35

Code:
#include <amxmodx> #include <amxmisc> #include <engine> new target[33]; public plugin_init() {   register_plugin("Sample", "1.0", "Zenith77");   register_cvar("kz_distance","5");   register_event("DeathMsg", "eventDeath", "a"); } public client_connect(id) {   target[id] = -1 } public eventDeath() {   new victim = read_data(2);   new i;       for(i=1; i<get_maxplayers(); i++){        if(!is_user_connected(i)) continue;        if(victim == target[i]) target[i] = -1;   } } public client_PreThink(id) {     new i;   for(i=1; i<get_maxplayers();i++) {        if(!is_user_connected(i) || !is_user_alive(i)) continue;                        new distance;        new origin[3];        new otherOrigin[3];        get_user_origin(id, origin, 0);        if(target[id] < 0)          get_user_origin(i, otherOrigin, 0);        else          get_user_origin(target[id], otherOrigin, 0);        distance = get_distance(origin, otherOrigin);        if(distance <= get_cvar_num("kz_distance") && target[id] < 0 ) {           target[id] = i;           entity_set_int(id, EV_INT_solid, SOLID_TRIGGER);           client_print(id, print_chat, "[KZ] Player detected, semi-clip set!");           break;        }        if(distance > get_cvar_num("kz_distance") && target[id]){           target[id] = -1;           entity_set_int(id, EV_INT_solid, SOLID_BBOX);           client_print(id, print_chat, "[KZ] Semi-clip unset!");        }    } }

Try that :)

Johnny Blaze 03-07-2006 17:57

I'll give that a try tomorrow, hopefully it will work :)
Thanks.

Zenith77 03-08-2006 15:21

Errors found, code edited :)

Johnny Blaze 03-09-2006 10:16

oo thanks, i didnt get a chance to test it yet, will try and give this one a test tonight. :)

errors on compile:

Error: Array must be indexed (variable "target") on line 45

:?

Zenith77 03-10-2006 14:49

Found n' Fixed

WaZZeR++ 03-10-2006 16:26

Try using find_ent_in_sphere insteed

And the commands for semiclip is
Code:
entity_set_int( id, EV_INT_solid, SOLID_SLIDEBOX)
and
Code:
entity_set_int( id, EV_INT_solid, SOLID_NOT)

Zenith77 03-10-2006 16:35

1) Good idea :) I always forget about that function

2) Not to sure about that one.

Johnny Blaze 03-11-2006 09:33

Thanks for fixing it again :)

however when I went to test it, as soon as I created a localserver and got in game, it detects me as another player and sets semiclip on me, even with no other players there, is there anyway to make it so it checks if the player found is the actual player.. if that makes sense, so like it only sets semiclip if the player found is not yourself?

Thanks again, your being a great help.

p3tsin 03-11-2006 13:43

Code:
if(id == i) continue


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

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