AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Client with that name... (https://forums.alliedmods.net/showthread.php?t=57685)

shine771 07-09-2007 07:48

Client with that name...
 
The script is SO easy, but i have problems with it that i Can't solve...

Code:
Code:

public death()
{
 new killed_player = read_data(2)
 
 new killed_name[32]
 get_user_name(killed_player,killed_name,31)
 
 if(get_pcvar_num(killed) == 1) {
  server_cmd("amx_ban %d %s %s", get_pcvar_num(bantime), killed_name, get_pcvar_num(reason))
 }
 else if(get_pcvar_num(killed) == 2) {
  server_cmd("amx_kick %s %s", killed_name, get_pcvar_num(reason))
 }
 return PLUGIN_CONTINUE
}

It doesn't do anything. Only in server console it shows:

Client With That Name Or Userid Not Found

I tried almost every way but it still doesn't work.
No errors Compiling.
Can someone help me?
Thanks

Alka 07-09-2007 08:56

Re: Client with that name...
 
Here is the correct way! :wink:

Code:

static const g_reason[] = "blah blah....."
 
public plugin_init() {
    ....
    register_event("DeathMsg", "death_msg", "a")
}
 
public death_msg()
{
    new victim = read_data(2)
 
    switch(get_pcvar_num(killed))
    {
          case 1:
              server_cmd("amx_ban #%i %d ^"%s^"", get_user_userid(victim), get_pcvar_num(bantime), g_reason)
 
          case 2:
              server_cmd("kick #%i ^"%s^"", get_user_userid(victim), g_reason)
    }
}

Also i see you use "get_pcvar_num(reason)" ,that is incorrect! You must use "get_pcvar_string(pcvar)" to get a string!

shine771 07-09-2007 08:57

Re: Client with that name...
 
Code:

register_event("DeathMsg", "death_msg", "a")
Code:

public death_ms()
:D

Thanks

EDIT: I know that's incorrect! But with get_pcvar_string it didn't work. I just tried get_pcvar_num and there were no errors. Then i posted here. And changed the script back: get_pcvar_string... And forgot to edit it here.

Rolnaaba 07-09-2007 21:47

Re: Client with that name...
 
Code:
String[156]; get_pcvar_string(pcvar, String, 155);
Code:

native get_pcvar_string(pcvar, string[], maxlen);


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

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