SA-MP Forums Archive
People In Mode count fails.... - 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: People In Mode count fails.... (/showthread.php?tid=278911)



People In Mode count fails.... - [MNC]Azz - 24.08.2011

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


Re: People In Mode count fails.... - WoodPecker - 24.08.2011

Can you show me your dialog ModeSelect please?


Re: People In Mode count fails.... - [MNC]Azz - 24.08.2011

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;
    }



Re: People In Mode count fails.... - iMonk3y - 24.08.2011

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


Re: People In Mode count fails.... - [MNC]Azz - 24.08.2011

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...


Re: People In Mode count fails.... - iMonk3y - 24.08.2011

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


Re: People In Mode count fails.... - [MNC]Azz - 24.08.2011

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....


Re: People In Mode count fails.... - iMonk3y - 24.08.2011

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...


Re: People In Mode count fails.... - [MNC]Azz - 24.08.2011

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

iMonk3y Reputation ++;


Re: People In Mode count fails.... - iMonk3y - 24.08.2011

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


Re: People In Mode count fails.... - [MNC]Azz - 24.08.2011

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...


Re: People In Mode count fails.... - iMonk3y - 24.08.2011

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;
}



Re: People In Mode count fails.... - [MNC]Azz - 24.08.2011

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