SA-MP Forums Archive
Gang kill rewards (NEED IDEA) - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Gang kill rewards (NEED IDEA) (/showthread.php?tid=649530)



Gang kill rewards (NEED IDEA) - MrakBuster - 10.02.2018

Hello community,

I am here again, today with just a little bit of IDEA help, since I can not figure it out.

What I need is, that I have 6 teams of gangs, and I want, that when player from any of these gangs kills player, that is in different gang(team), he will get rewarded for that kill.

I have idea where I need to work with it - OnPlayerDeath and I need to use killerid, perhaps some loops, this is what I constructed so far, but was not enable to continue, since I just did not know, what to script next - i did not get the idea, how to do it.

PHP код:
    for(new 0MAX_PLAYERSi++)
    {
        if(
PlayerInfo[i][pJob] == 9// Grove
        
{
            if( 
So I made a loop, so I will find players, that are in Gang "Grove", which on pJob is set on 9. Than I probably wanted to figure out, who they killed, and if the killed ones were different gang, i would reward them.

However I want to reward them only if they kill a member of different gang (not all players).

If you guys could contribute with any solutionable ideas, I would appreciate it more, than you think.


Re: Gang kill rewards (NEED IDEA) - JasonRiggs - 10.02.2018

First you must save the team of every player into enums or VarInt, then check if the dead guy's team differs from the killer, if yes then award the killer, easy..


Re: Gang kill rewards (NEED IDEA) - Gammix - 10.02.2018

OnPlayerDeath have to arguments - "playerid" and "killerid".

So i assume you are not using SetPlayerTeam, otherwise there is no way a team member can kill another team member.

So you can just compare the way you checked the team in loop:
PHP код:
if (PlayerInfo[playerid][pJob] != PlayerInfo[killerid][pJob]) {} 
And if this statement is true, you continue your loop inside it. About your loop, you need to modify it to this (you only want to give score to connected gang members right?):
PHP код:
for (new 0GetPlayerPoolSize(); <= ji++) {
    if (
IsPlayerConnected(i)) {
        
// do your if statements here
    
}




Re: Gang kill rewards (NEED IDEA) - MrakBuster - 11.02.2018

Yes, however the thing is, that in pJob, there are for example cops or taxidrivers too, and I do not want gang members to get money from killing them.


Re: Gang kill rewards (NEED IDEA) - Astralis - 11.02.2018

Quote:
Originally Posted by MrakBuster
Посмотреть сообщение
Yes, however the thing is, that in pJob, there are for example cops or taxidrivers too, and I do not want gang members to get money from killing them.
Check the team id's before giving awards.