AlliedModders

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

r4ndomz 02-03-2010 17:11

get_user_name help
 
I wrote out this thing and for some reason when id use it, itd say the killer of the victim has died, and not the person thats died him/herself. So i added victim and killer, and it doesnt compile..

PHP Code:

#include <amxmodx>
#include <amxmisc>
#include <fun>
#include <engine>
#include <cstrike>
#include <csx>


public plugin_precache()
{
    
precache_sound("misc/chucky1.wav")
}

public 
plugin_init()
{
    
register_plugin("move","r4nDoMz","1.0")
    
register_event("client_death","client_death","a")
}

public 
client_death(id)
{    
    new 
weapon get_user_weapon(id)
    new 
Killer read_data(1)
    new 
Victim read_data(2)

    if(
weapon == CSW_KNIFE)
    {
        
get_user_name(Victim)
        
get_user_name(Killer)
        
client_print(0print_center"%s killed %s with a knife!!!"KillerVictim)     
        
client_cmd(0,"spk sound/misc/chucky1.wav")
    }
    else
    {
        
get_user_name(Killer)
        
get_user_name(Victim)
        
client_print(0print_chat"Player %s was killed by %s!!!"VictimKiller
    }


PHP Code:

//AMXXPC compile.exe
// by the AMX Mod X Dev Team


//// knifelol.sma
// C:\Documents and Settings\nick\Desktop\compiler1\knifelol.sma(28) : error 088
number of arguments does not match definition
// C:\Documents and Settings\nick\Desktop\compiler1\knifelol.sma(29) : error 088
number of arguments does not match definition
// C:\Documents and Settings\nick\Desktop\compiler1\knifelol.sma(35) : error 088
number of arguments does not match definition
// C:\Documents and Settings\nick\Desktop\compiler1\knifelol.sma(36) : error 088
number of arguments does not match definition
//
// 4 Errors.
// Could not locate output file C:\Documents and Settings\nick\Desktop\compiler1
\compiled\knifelol.amx (compile failed).
//
// Compilation Time: 0.42 sec
// ----------------------------------------

Press enter to exit ... 


fysiks 02-03-2010 17:13

Re: get_user_name help
 
PHP Code:

new szName[32]
get_user_name(idszNamecharsmax(szName))
client_print(0print_chat"Player name is: %s"szName


r4ndomz 02-03-2010 19:40

Re: get_user_name help
 
Quote:

Originally Posted by fysiks (Post 1077564)
PHP Code:

new szName[32]
get_user_name(idszNamecharsmax(szName))
client_print(0print_chat"Player name is: %s"szName


for that would i need to put Killer and Victim for id? or no?

EDIT:
ok i tried it, compiles fine...now to test!

EDIT:EDIT:
hmm...tested it out, and i hear the sound, i see the text, but the players names arent appearing. Just says " killed with a knife!!!"

Mxnn 02-03-2010 19:55

Re: get_user_name help
 
Killer and Victim are 2 id's.
You must put 2 arrays that will contain the killers & victims name.
As fysiks said, you have to put:
Quote:

Originally Posted by fysiks (Post 1077564)
PHP Code:

new szName[32]
get_user_name(idszNamecharsmax(szName))
client_print(0print_chat"Player name is: %s"szName


In get_user_name, instead of id you have to put Killer to get the Killer's name and put again the stuff but instead of Killer, put Victim.
Stuff will be this:
PHP Code:

new szVictimName[32], szKillerName[32]
get_user_name(VictimszVictimNamecharsmax(szVictimName))
get_user_name(KillerszKillerNamecharsmax(szKillerName))
client_print(0print_chat"Killer : %s, Victim: %s"szKillerNameszVictimName


r4ndomz 02-03-2010 20:41

Re: get_user_name help
 
Quote:

Originally Posted by Mxnn (Post 1077692)
Killer and Victim are 2 id's.
You must put 2 arrays that will contain the killers & victims name.
As fysiks said, you have to put:


In get_user_name, instead of id you have to put Killer to get the Killer's name and put again the stuff but instead of Killer, put Victim.
Stuff will be this:
PHP Code:

new szVictimName[32], szKillerName[32]
get_user_name(VictimszVictimNamecharsmax(szVictimName))
get_user_name(KillerszKillerNamecharsmax(szKillerName))
client_print(0print_chat"Killer : %s, Victim: %s"szKillerNameszVictimName


Ok so i tried that, and now it shows:
>cNs< HideNseek *Is Back* killed >cNs< HideNseek *Is Back

Mxnn 02-03-2010 22:35

Re: get_user_name help
 
:| ?
If you put that i put, the server will show "Killer: KILLER_NAME, Victim: VICTIM_NAME" and no more else.

fysiks 02-03-2010 23:42

Re: get_user_name help
 
PHP Code:

register_event("DeathMsg", . . . 


tuty 02-04-2010 02:17

Re: get_user_name help
 
you can check player weapon in deathmessage with read_data( 4, ... );

and you have a bad code right there

r4ndomz 02-04-2010 06:59

Re: get_user_name help
 
Quote:

Originally Posted by Mxnn (Post 1077774)
:| ?
If you put that i put, the server will show "Killer: KILLER_NAME, Victim: VICTIM_NAME" and no more else.

PHP Code:

client_print(0print_center"%s has killed %s with a KNIFE!!"szKillerNameszVictimName

Thats whats there. Looks the same or its only possible to do it if you do that?

ProIcons 02-04-2010 07:13

Re: get_user_name help
 
PHP Code:

public plugin_init()
{
    
register_plugin("move","r4nDoMz","1.0")
    
register_event("DeathMsg""client_death""a""1>0")
}

public 
client_death()
{    
    new 
Killer[32],Victim[32]
    new 
Killernum read_data(1)
    new 
Victimnum read_data(2)
    static 
weapon_name[24];
    
read_data(4,weapon_name,23);
    
get_user_name(Killernum,Killer,31);
    
get_user_name(Victimnum,Victim,31);
    if (
equal(weapon_name,"knife"))
    {
        
client_print(0print_center"%s killed %s with a knife!!!"KillerVictim)     
        
client_cmd(0,"spk sound/misc/chucky1.wav")
    }
    else
    {
        
client_print(0print_chat"Player %s was killed by %s!!!"VictimKiller
    }


EDITED Change this two Codes


All times are GMT -4. The time now is 07:27.

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