Raised This Month: $12 Target: $400
 3% 

Feature for a KZ plugin.. Need Help :)


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Johnny Blaze
Junior Member
Join Date: Dec 2005
Old 03-07-2006 , 11:47   Feature for a KZ plugin.. Need Help :)
Reply With Quote #1

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.
Johnny Blaze is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 03-07-2006 , 15:35  
Reply With Quote #2

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
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Johnny Blaze
Junior Member
Join Date: Dec 2005
Old 03-07-2006 , 17:57  
Reply With Quote #3

I'll give that a try tomorrow, hopefully it will work
Thanks.
Johnny Blaze is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 03-08-2006 , 15:21  
Reply With Quote #4

Errors found, code edited
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Johnny Blaze
Junior Member
Join Date: Dec 2005
Old 03-09-2006 , 10:16  
Reply With Quote #5

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

Johnny Blaze is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 03-10-2006 , 14:49  
Reply With Quote #6

Found n' Fixed
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
WaZZeR++
Veteran Member
Join Date: Mar 2005
Location: Sweden
Old 03-10-2006 , 16:26  
Reply With Quote #7

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)
WaZZeR++ is offline
Send a message via MSN to WaZZeR++
Zenith77
Veteran Member
Join Date: Aug 2005
Old 03-10-2006 , 16:35  
Reply With Quote #8

1) Good idea I always forget about that function

2) Not to sure about that one.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Johnny Blaze
Junior Member
Join Date: Dec 2005
Old 03-11-2006 , 09:33  
Reply With Quote #9

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.
Johnny Blaze is offline
p3tsin
Senior Member
Join Date: Sep 2005
Location: Finland
Old 03-11-2006 , 13:43  
Reply With Quote #10

Code:
if(id == i) continue
__________________
plop
p3tsin is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 03:50.


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