AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Returning Server's name instead of Player name (https://forums.alliedmods.net/showthread.php?t=192809)

Waleed 08-14-2012 10:02

Returning Server's name instead of Player name
 
Hey Guys, I am back after few months, I was working in PHP. I forgot allot of things in SMALL. Here I am trying to get the name of the player who has died. But There is some problem in it. In game, When I kill somebody or get killed I should get the message "somebody has been shot to death!", But in game I am getting "My-Server has been shot to death".
I dont know how to get the name properly. It is returning the server name.

Code:
#include <amxmodx> #include <amxmisc> public  plugin_init() {     register_plugin("Gameplay1","1.0","Waleed");     register_event("DeathMsg", "hook_death", "a", "1>0") } public  hook_death(id) {     new name[32]     get_user_name(id, name, charsmax(name))     client_print(id, print_chat, " %s has been shot to death!", name) }

I have new ideas but stuck at the starting xD
Sorry for asking such a newbie question :D
Thnx:)

ConnorMcLeod 08-14-2012 10:04

Re: Returning Server's name instead of Player name
 
http://www.amxmodx.org/funcwiki.php?...vent&go=search

Waleed 08-14-2012 10:53

Re: Returning Server's name instead of Player name
 
Quote:

Originally Posted by ConnorMcLeod (Post 1771187)

Can you tell me what's wrong So I can look at func wiki knowing my mistake.

EpicMonkey 08-14-2012 10:54

Re: Returning Server's name instead of Player name
 
Well read the example part in the link he posted and you'll know whats wrong

lucas_7_94 08-14-2012 12:04

Re: Returning Server's name instead of Player name
 
First, DeathMsg doesnt have params , if you want to get killer/victim use read_data , see Connor's post.

Napoleon_be 08-14-2012 21:16

Re: Returning Server's name instead of Player name
 
to get the name of the killing player, use read_data(1).

fysiks 08-14-2012 22:49

Re: Returning Server's name instead of Player name
 
Quote:

Originally Posted by Napoleon_be (Post 1771663)
to get the name of the killing player, use read_data(1).

Really? Why do people need to answer a question that has already been answered?

Give a man a fish . . . .

Liverwiz 08-15-2012 00:21

Re: Returning Server's name instead of Player name
 
Quote:

Originally Posted by fysiks (Post 1771708)

Give a man a fish . . . .

LOL. Some people just get confused with a raw fish if it hasn't already been battered, deep fried, shoved in plastic wrap, and printed directions on how to microwave it. (me included in certain states of mind)

EpicMonkey 08-15-2012 04:08

Re: Returning Server's name instead of Player name
 
Quote:

Originally Posted by fysiks (Post 1771708)
Really? Why do people need to answer a question that has already been answered?

Give a man a fish . . . .

We got crabs ... :crab::crab: , couldnt find any fishes :3

ConnorMcLeod 08-15-2012 05:07

Re: Returning Server's name instead of Player name
 
Quote:

Originally Posted by fysiks (Post 1771708)
Really? Why do people need to answer a question that has already been answered?

Give a man a fish . . . .

Don't blame him, he started his post before me, but it took him roughly 11 hours and 15 min to answer, so few people had already answered when he hit the submit button.


About the question, use read_data(1) to get killer index so you can use get_user_name with that index.


All times are GMT -4. The time now is 05:48.

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