AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   need help with making user specific cvars (https://forums.alliedmods.net/showthread.php?t=11591)

[cTs] Strake*ROC* 03-23-2005 22:40

need help with making user specific cvars
 
Hey guys,

I do a lot of plugin making, and i am making my first ever "mod" and i am trying to make it so an admin can do "amx_wanted" and make a user "Wanted" (EX: Player Bob is wanted for TKing. Bounty: $1000)

and i want to make it so it checks: if when a player is killed, is he wanted?

so far i have the easy stuff like:

Code:

register_event("DeathMsg", "hook_death", "a", "1>0")
and

Code:

        new Killer = read_data(1)
        new Victim = read_data(2)

it checks to see if the player is wanted.

if so, then give Killer $1000 else plugin_continued

If you guys could help me with this... that would be great :)

Thanks Guys,
Strake

XxAvalanchexX 03-24-2005 00:26

Make a variable, let's say "new wanted[33];". The array size is 33 so that we can store ids from 1-32, each representing a player in the game.

In the command that handles amx_wanted, use cmd_target to get the target. Set wanted[theirplayerid] to 1. When a player leaves, make sure to reset wanted[theirplayerid] back to 0.

On death, see if wanted[theirplayerid] is 1.

[cTs] Strake*ROC* 03-24-2005 19:06

yeah, but how do i do that... how do i make is so the array is the users id? thats the part that i dont understand....

v3x 03-24-2005 22:59

Code:
new wanted[id]

XxAvalanchexX 03-24-2005 23:24

No, v3x, no... :-\

Code:
#include <amxmodx> #include <amxmisc> new wanted[33]; public plugin_init() {    register_concmd("amx_wanted","cmd_wanted",ADMIN_KICK,"<user> <0|1> - makes a user wanted"); } public client_disconnect(id) {    wanted[id] = 0; } public cmd_wanted(id,level,cid) {    if(!cmd_access(id,level,cid,3)) {       return PLUGIN_HANDLED;    }    new arg[32];    read_argv(1,arg,31);    new target = cmd_target(id,arg,3);    read_argv(2,arg,31);    new status = str_to_num(arg);    if(!target) {       return PLUGIN_HANDLED;    }    wanted[target] = status;    new username[32];    get_user_name(target,username,31);    console_print(id,"* %s is %s wanted",username,(status == 1) ? "now" : "no longer");    return PLUGIN_HANDLED; }

Using that setup, you can check if wanted[Victim] is 1 or not on DeathMsg to see if they are wanted.

[cTs] Strake*ROC* 03-24-2005 23:49

That man... i've always wondered how to do this, but never had a chance to sit down and learn how to do that... i'll study the code, learn, then put into my plugin...

Thanks!,
Strake


All times are GMT -4. The time now is 10:01.

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