Need some help with OnPlayerDeath
#1

Hey there, so basically I have been working on a 3vs3 duel system, and I have finished everything but there's one thing I'm stuck with.

So, here's how I did for 1 vs 1:

pawn Code:
new inviterid = e_DuelInfo[playerid][E_DUEL_STARTER];
        if(e_DuelInfo[inviterid][E_DUEL_LINEUP] == 1) {

            format(string, sizeof(string), "[DUEL - 1vs1]: {FFFFFF}%s has won the duel against %s.", GetName(killerid), GetName(playerid));
            SpawnUser(playerid);
            SpawnUser(killerid);

            e_DuelInfo[inviterid][E_DUEL_INVITED] = 0;
            e_DuelInfo[inviterid][E_DUEL_ACCEPTED] = 0;

            e_DuelInfo[playerid][E_DUEL_INVITED] = 0;
            e_DuelInfo[playerid][E_DUEL_ACCEPTED] = 0;
        }
But I have no idea how to do it for 2vs2+, because if I'm dueling 2vs2 with someone as soon as one player kills another the duel is over, I want it to be like so when all the players of a team die, the duel ends. Here's how I define opponents and teammates:

It would be something like this probably:

pawn Code:
if(e_DuelInfo[inviterid][E_DUEL_LINEUP] == 2) {

            ...
        }

        if(e_DuelInfo[inviterid][E_DUEL_LINEUP] == 3) {

            ...
        }
e_DuelInfo[playerid][E_DUEL_LINEUP] = 1; - 1 vs 1
e_DuelInfo[playerid][E_DUEL_LINEUP] = 2; - 2 vs 2
e_DuelInfo[playerid][E_DUEL_LINEUP] = 3; - 3 vs 3

pawn Code:
E_DUEL_OPPONENT[3],
E_DUEL_TEAMMATE[2],
Reply
#2

Hello! I would define two global variables, once per duelling team, and increase it for every player in a team; when dying if players are in a duel team decrease the variable. Once it's 0 the duel is over and the other team won.
Reply
#3

Quote:
Originally Posted by v1k1nG
View Post
Hello! I would define two global variables, once per duelling team, and increase it for every player in a team; when dying if players are in a duel team decrease the variable. Once it's 0 the duel is over and the other team won.
Can you give me an example to that please?
Reply
#4

I know it's quite different from your code, sorry for that

PHP Code:
// I will suppose that there are 2 duelling teams
#define TEAM_DUEL_ONE     0
#define TEAM_DUEL_TWO     1
#define MAX_DUEL_TEAMS     2
new InviterID
InvitedID
boolIsPlayerInvitedToDuel[MAX_PLAYERS],
PlayersInTeam[MAX_DUEL_TEAMS]; // <- this will be important
// Somewhere, command or anything else after the duel invitation gets accepted
InviterID playerid;
InvitedID invitedid;
IsPlayerInvitedToDuel[playerid] = true;
IsPlayerInvitedToDuel[invitedid] = true;
PlayersInTeam[TEAM_DUEL_ONE]++; // playerid just joined team 1!
PlayersInTeam[TEAM_DUEL_TWO]++; // invitedid just joined team 2!
// Here we will ask to playerid and invitedid to add 2 players in their duelling team
// When someone accepts to join their squad increment PlayersInTeam and switch IsPlayerInvitedToDuel to true condition
// Now under OnPlayerDeath if IsPlayerInvitedToDuel[playerid] == true decrement PlayersInTeam[dead player team]
// If PlayersInTeam[TEAM_DUEL_ONE] <= 0 TEAM_DUEL_TWO wins and viceversa. 
Reply
#5

Quote:
Originally Posted by v1k1nG
View Post
I know it's quite different from your code, sorry for that

PHP Code:
... 
Thanks, but I managed to do it by doing multiple checks and adding other enums. It was easier than I thought.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)