People In Mode count fails....
#1

So heres my code:

pawn Code:
new PPLinTDM;
new PPLinFFA;
new IsInTDM[MAX_PLAYERS];
new IsInFFA[MAX_PLAYERS];
Players choose TDM or FFA when they connect with a dialog which sets
pawn Code:
IsInTDM[playerid] = 1;
or
pawn Code:
IsInFFA[playerid] = 1;
When they spawn:
pawn Code:
public OnPlayerSpawn(playerid)
{
if(IsInTDM[playerid] == 1)
{
PPLinTDM ++;
}
if(IsInFFA[playerid] == 1)
{
PPLinFFA ++;
}
return 1;
}
When they die:
pawn Code:
public OnPlayerDeath(killerid,playerid,reason)
{
if(IsInTDM[playerid] == 1)
{
PPLinTDM --;
}
if(IsInFFA[playerid] == 1)
{
PPLinFFA --;
}
return 1;
}
And now to the problem:
With this command people are meant to change from TDM to FFA or reverse(that works), and it also is meant to show the number of people playing in the modes...
pawn Code:
if (strcmp("/changemode", cmdtext, true, 10) == 0)
    {
    new string[256];
    ForceClassSelection(playerid);
    format(string,sizeof(string),"Team Deathmatch (Players: %d)\nFree For All(Players: %d)",PPLInTDM,PPLInFFA);
        ShowPlayerDialog(playerid,ModeSelect,DIALOG_STYLE_LIST,"Choose Mode",string,"Continue","Cancel");
        //When the player chooses the mode in the dialog it kills him and forces class selection...
    return 1;
    }
Ill explain with an example:
When i enter the game and choose tdm its fine, i use /changemode and it shows 1 person is in TDM which is me... so i change to FFA.... use command again and it now shows there is 1 person in TDM and 1 person in FFA...(there are no other players except me on the server) And if i change back to TDM and then use command agait it shows 2 people in TDM and 1 person in FFA...
WTF is wrong with my code or is OnPlayerDeath not called
Reply
#2

Can you show me your dialog ModeSelect please?
Reply
#3

Quote:
Originally Posted by WoodPecker
View Post
Can you show me your dialog ModeSelect please?
Sure:

pawn Code:
if(dialogid == ModeSelect)
    {
        if(response)
        {
            if(listitem == 0)
            {
            IsInTDM[playerid] = 1;
            IsInFFA[playerid] = 0;
            IsInSTUNT[playerid] = 0;//ignore this
            SendClientMessage(playerid,COLOR_ORANGE,"**TDM Chosen**");
            SetPlayerHealth(playerid,0.0);
            }
            if(listitem == 1)
            {
            IsInTDM[playerid] = 0;
            IsInFFA[playerid] = 1;
            IsInSTUNT[playerid] = 0;//ignore this
            SendClientMessage(playerid,COLOR_ORANGE,"**FFA Chosen**");
            SetPlayerHealth(playerid,0.0);
            }

        }
        return 1;
    }
Reply
#4

When you use command "/changemode", it doesn't reduce PPLinTDM/PPLinFFA value... that's why.
Reply
#5

Quote:
Originally Posted by iMonk3y
View Post
When you use command "/changemode", it doesn't reduce PPLinTDM/PPLinFFA value... that's why.
Well its not meant to when u use it... It reduces the value when he dies but it doesnt... When u use the command the second time it still shows that theres some1 in TDM...
Reply
#6

Of course it won't reduce value OnPlayerDeath if you choose TDM while you're still FFAing. Get it?
Reply
#7

Quote:
Originally Posted by iMonk3y
View Post
Of course it won't reduce value OnPlayerDeath if you choose TDM while you're still FFAing. Get it?
But doesnt the dialog change the value? Then it kills me and i should have a different value....
Reply
#8

Example:

Code:
Player is FFA-ing (IsInFFA[playerid] = 1;)

Player chooses to change mode (IsInTDM[playerid] = 1;)

Ups.. this line is unnecessary

OnPlayerDeath
{
    if(IsInTDM[playerid] == 1) <== Player isn't TMD-ing yet, but this statement will get called...
    {
        PPLinFFA++; <== and dummies in FFA will increase!
    }

}
Or whatever... I tried my best. If all else fails, read some instructions...
Reply
#9

OMG im so dumb.... Thanks iMonk3y that helped
so how should i do it so it doesnt mess up?

iMonk3y Reputation ++;
Reply
#10

Always welcome and thanks I could fix that... if you got PLENTY of time...
Reply
#11

Quote:
Originally Posted by iMonk3y
View Post
Always welcome and thanks I could fix that... if you got PLENTY of time...
Yh if you dont mind... Im not in a rush...
Reply
#12

You could cut code from OnPlayerDeath (since it's useless) and paste it OnDialogResponse.

Like so:

pawn Code:
if(dialogid == ModeSelect)
{
    if(response)
    {
        if(listitem == 0)
        {
            if(IsInFFA[playerid] == 1)
            {
                PPLinFFA --;
            }
            IsInTDM[playerid] = 1;
            IsInFFA[playerid] = 0;
            IsInSTUNT[playerid] = 0;//ignore this
            SendClientMessage(playerid,COLOR_ORANGE,"**TDM Chosen**");
            SetPlayerHealth(playerid,0.0);
        }
        if(listitem == 1)
        {
            if(IsInTDM[playerid] == 1)
            {
                PPLinTDM --;
            }
            IsInTDM[playerid] = 0;
            IsInFFA[playerid] = 1;
            IsInSTUNT[playerid] = 0;//ignore this
            SendClientMessage(playerid,COLOR_ORANGE,"**FFA Chosen**");
            SetPlayerHealth(playerid,0.0);
        }
    }
    return 1;
}
Reply
#13

You sirr deserve a cake.. a HUGE CAKE!!! Im so dumb... thanks a lot... u really helped me out
iMonk3y Cake's += 10000000; :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)