Hey there! I'm just started my experience with SourcePawn and Sourcemod as well and I've got some problems right now. Its too hard for me to get rid of them, but I'm sure you guys can easily solve them.
First of all, this is the original plugin
I just wanna to upgrade one of this plugin's function.
So, I have my own football-based map. If a player(for example CT) scores a goal then all enemy team(T) will be killed by trigger_hurt. In plugin there are function which give "1" frag(1 point) for the goal-scoring player. But all the players who were killed by the trigger_hurt gets "-1" frag in their statistic. And this is what I want to change.
There are a piece of code with this function(goalscorer):
Spoiler
PHP Code:
new String:LastAttacker[512]; new LastAttackerUser;
1. I want to give a "1" frag(point) to the all dead players. Thats is because if someone from the dead players have already scored a goal early, he then won't lost his own goal statistic(frags).
Hope you understand my idea. 2. I want to remove a possibility to gain a frag when you're scoring an own goal.
There are the original piece of code with this function:
public Event_MixRoundEnd(Handle:event, const String:name[], bool:dontBroadcast) { // Add frag to the winner new cFrags = GetClientFrags(LastAttackerUser); new nFrags = cFrags + 1; SetclientFrags(LastAttackerUser, nFrags);
if ( LastAttackerUser != -1 ) { PrintToChatAll("\x04Soccer\x05 |\x03 Player\x04 %s\x05 Scored\x03 on this round\x04!", LastAttacker); } LastAttackerUser = -1;
This piece of code seems understandable but what means this string: "LastAttackerUser != -1"?
Also I has prepared a solutions for my own questions. 1.
Spoiler
PHP Code:
HookEvent("player_hurt", Event_MixRoundEnd) new FragsForDead = GetClientFrags(***); new nFragsForDead = FragsForDead + 1; SetclientFrags(LastAttackerUser, nFrags);
I'm using "player_hurt" event because on my map there are only one way that you can die and this is "trigger_hurt". Maybe there are more easier solution with the "player_death" just let me know about it. So, the main problem is here: what do I need to type instead of "***"?
Do I need to make an another hook-function like "public Action:OnEntityTakeDamage" or what?
Can't solve this by myself :c 2.
Spoiler
PHP Code:
HookEvent("player_hurt", Event_RoundEndPoints) public Event_RoundEndPoints(Handle:event, const String:name[], bool:dontBroadcast) { new FragsForDead = GetClientFrags(***); new nFragsForDead = FragsForDead + 1; SetclientFrags(LastAttackerUser, nFragsForDead); if( LastAttackerUser = dead) // don't know how to type this condition correct :c { FragsForDead = GetClientFrags (LastAttackerUser) nFragsForDead = FragsForDead - 2; // give an own-scorer "-1" frag in his stats SetclientFrags(LastAttackerUser, nFragsForDead); } }
There I dont know how to let the plugin know that the LastAttackerUser is dead :c
Thats all for now, hope you can understand my poor English c;
P.S. Almost forgot bout it. How can I check this plugin for working in CS:GO? Is there any methods to check it except just putting my plugin at the server?
Last edited by BlackHawk1337; 03-09-2016 at 16:30.
in OnEntityCreated, the edict should be the soccerball if you want to make soccer mod scorer.
So, LastAttackerUser will be the index of the player who kicked soccerball recently.
PHP Code:
public OnPluginStart() { HookEvent("player_death", Event_PlayerDeath); HookEvent("round_end", Event_RoundEnd); }
public Event_PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast) { new client = GetClientOfUserId(GetEventInt(event, "userid")); // this is *** wut u wanted!
new FragsForDead = GetClientFrags(client); // Let's get the frags of dead person(client). new nFragsForDead = FragsForDead + 1; // <client's frags>+1 SetClientFrags(client, nFragsForDead); // It should be 'client' not 'LastAttackerUser' if u want sensible way for this. }
public Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast) { // WELL... I DON'T KNOW Y U WANT TO GIVE MINUS SCORE TO FRAGGER... if( IsPlayerAlive(LastAttackerUser) ) // Is the fragger alive? { FragsForDead = GetClientFrags (LastAttackerUser); // Get Fragger's score nFragsForDead = FragsForDead - 2; // give an own-scorer "-1" frag in his stats SetClientFrags(LastAttackerUser, nFragsForDead); } }
Y did I Hook round_end and set fragger's score on it:
'cuz player_death fired when every single player dies.
for example,
there's 5 players on CT and also 5 players on T.
when a T player make a goal, all of CT players die.
then player_death fired 5 times. ('cuz 5 players died!)
I thought u want to set fragger's score just one time.