Raised This Month: $ Target: $400
 0% 

No -1 frag on suicide


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
I'mSane
Member
Join Date: Apr 2010
Location: SPb, Russia
Old 04-13-2010 , 07:21   No -1 frag on suicide
Reply With Quote #1

How to disable -1 kill on suicide?
I'mSane is offline
Send a message via Skype™ to I'mSane
FaTony
Veteran Member
Join Date: Aug 2008
Old 04-13-2010 , 12:55   Re: No -1 frag on suicide
Reply With Quote #2

Hook it, hook what it affects, add 1.
FaTony is offline
I'mSane
Member
Join Date: Apr 2010
Location: SPb, Russia
Old 04-15-2010 , 13:49   Re: No -1 frag on suicide
Reply With Quote #3

public OnPluginStart()
{
HookEvent("player_death", Event_PlayerDeath);
}

public Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
new client = GetClientOfUserId(GetEventInt(event, "userid"));
if (GetEventInt(event, "attacker") == world)
{
new Score = GetClientFrags(client)+1;

SetEntProp(client, Prop_Data, "m_iFrags", Score);

return Plugin_Continue;
}
}


does not works.
__________________
Sorry for noob questions.
Sorry for bad english.
I'mSane is offline
Send a message via Skype™ to I'mSane
selax
AlliedModders Donor
Join Date: Apr 2008
Location: Moscow
Old 04-15-2010 , 14:18   Re: No -1 frag on suicide
Reply With Quote #4

Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new victim_id = GetClientOfUserId(GetEventInt(event, "userid"));
    new attacker_id = GetClientOfUserId(GetEventInt(event, "attacker"));
    if (attacker_id == 0 || victim_id == attacker_id)
    {
        SetEntProp(victim_id, Prop_Data, "m_iFrags", GetClientFrags(victim_id) + 1);
    }
}
selax is offline
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 04-15-2010 , 23:03   Re: No -1 frag on suicide
Reply With Quote #5

GetClientOfUserId() returns client, not integer. or I thinking wrong?

PHP Code:
public OnPluginStart()
{
    
HookEvent("player_death",Event_PlayerDeath,EventHookMode_Pre);
}

public 
Action:Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new 
victim_id GetEventInt(event"userid");
    new 
attacker_id GetEventInt(event"attacker");
    if (
attacker_id == || victim_id == attacker_id)
        return 
Plugin_Handled;

__________________

Last edited by Leonardo; 04-15-2010 at 23:07.
Leonardo is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 04-15-2010 , 23:41   Re: No -1 frag on suicide
Reply With Quote #6

"client" is a number from 1 to MaxClients so it is integer.
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
Leonardo
Veteran Member
Join Date: Feb 2010
Location: 90's
Old 04-16-2010 , 03:05   Re: No -1 frag on suicide
Reply With Quote #7

"client" is a client's index
"userid" is a client's id
so what's the difference?
__________________
Leonardo is offline
I'mSane
Member
Join Date: Apr 2010
Location: SPb, Russia
Old 04-16-2010 , 11:20   Re: No -1 frag on suicide
Reply With Quote #8

Quote:
Originally Posted by SelaX View Post
Code:
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
{
    new victim_id = GetClientOfUserId(GetEventInt(event, "userid"));
    new attacker_id = GetClientOfUserId(GetEventInt(event, "attacker"));
    if (attacker_id == 0 || victim_id == attacker_id)
    {
        SetEntProp(victim_id, Prop_Data, "m_iFrags", GetClientFrags(victim_id) + 1);
    }
}
lol it adds one frag on suicide, but I need just "no -1"
__________________
Sorry for noob questions.
Sorry for bad english.
I'mSane is offline
Send a message via Skype™ to I'mSane
Annihilator
Senior Member
Join Date: Nov 2006
Location: Lithuania
Old 04-16-2010 , 11:26   Re: No -1 frag on suicide
Reply With Quote #9

If it adds 1 with +1, instead of taking one away, wont your problem be solved if you just delete the +1?
Annihilator is offline
exvel
SourceMod Donor
Join Date: Jun 2006
Location: Russia
Old 04-16-2010 , 11:30   Re: No -1 frag on suicide
Reply With Quote #10

Quote:
Originally Posted by Leonardo View Post
"client" is a client's index
"userid" is a client's id
so what's the difference?
userid - number unique for each client ever connected to the server
client index - number in the range 1...MaxClients (usually from 1 to 64) that is actual entity number for the player. It is used in the almost all sourcemod functions
__________________
For admins: My plugins

For developers: Colors library
exvel is offline
Send a message via ICQ to exvel
Reply



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 13:39.


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