SA-MP Forums Archive
[HELP]How to made - 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: [HELP]How to made (/showthread.php?tid=613012)



[HELP]How to made - Hunud - 23.07.2016

I there any way why how to make players count who is in DM example Sniper DM: 2 players ?


Re: [HELP]How to made - K0P - 23.07.2016

Make a global array variable:

Код:
new InDM[MAX_PLAYERS];
Set its value to 1 when the player joins the deathmatch

Код:
new InDM[playerid] = 1;
Set its value to 0 when the player leaves the deathmatch

Код:
new InDM[playerid] = 0;
Also set its value to 0 when the layer disconnects so it wont effect the other players who join the server

Код:
new InDM[playerid] = 0;
Now make a loop and count the players in deathmatch

Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        if(InDM[i] == 1)
        {
            count++;
        }
    
    }
}
Example command:

Код:
CMD:playersindm(playerid, params[])
{
    new count;
    new string[50];

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(InDM[i] == 1)
            {
                count++;
            }   
        }
    }

    format(string, sizeof(string), "There are %d players in deathmatch", count);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
}



Re: [HELP]How to made - Kaliber - 23.07.2016

Sure...you do sth like this:

PHP код:
//@top of the script
new sniperCounter,bool:inSniper[MAX_PLAYERS char];
//If the player enters the sniper Arena
if(!inSniper{playerid})
{
    
sniperCounter++;
    
inSniper{playerid} = true;
}
//If the player leaves the sniper
sniperCounter--;
inSniper{playerid} = false;
//If the player disconnects
if(inSniper{playerid})
{
    
sniperCounter--;
    
inSniper{playerid} = false;
}
//And the value of sniperCounter = the player amount who are there 



Re: [HELP]How to made - Hunud - 23.07.2016

Quote:
Originally Posted by K0P
Посмотреть сообщение
Make a global array variable:

Код:
new InDM[MAX_PLAYERS];
Set its value to 1 when the player joins the deathmatch

Код:
new InDM[playerid] = 1;
Set its value to 0 when the player leaves the deathmatch

Код:
new InDM[playerid] = 0;
Also set its value to 0 when the layer disconnects so it wont effect the other players who join the server

Код:
new InDM[playerid] = 0;
Now make a loop and count the players in deathmatch

Код:
for(new i = 0; i < MAX_PLAYERS; i++)
{
    if(IsPlayerConnected(i))
    {
        if(InDM[i] == 1)
        {
            count++;
        }
    
    }
}
Example command:

Код:
CMD:playersindm(playerid, params[])
{
    new count;
    new string[50];

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(InDM[i] == 1)
            {
                count++;
            }   
        }
    }

    format(string, sizeof(string), "There are %d players in deathmatch", count);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
}
I want this but without CMDlayersindm i wanna like when player enter in dm it say Hunud has joined in sniper dm - Total players: 1.


Re: [HELP]How to made - FuNkYTheGreat - 23.07.2016

Quote:
Originally Posted by K0P
Посмотреть сообщение
Make a global array variable:

Код:
new InDM[MAX_PLAYERS];
Set its value to 1 when the player joins the deathmatch

Код:
new InDM[playerid] = 1;
Set its value to 0 when the player leaves the deathmatch

Код:
new InDM[playerid] = 0;
Also set its value to 0 when the layer disconnects so it wont effect the other players who join the server

Код:
new InDM[playerid] = 0;
Add this where u want to count
Код:
    new count;
    new string[50];

    for(new i = 0; i < MAX_PLAYERS; i++)
    {
        if(IsPlayerConnected(i))
        {
            if(InDM[i] == 1)
            {
                count++;
            }   
        }
    }

    format(string, sizeof(string), "%s Has Joined in Sniper DM Total players %d  ",GetName(playerid),count);
    SendClientMessage(playerid, 0xFFFFFFFF, string);
    return 1;
}
Код:
GetName(playerid)
{
	new pName[24];
	GetPlayerName(playerid, pName, 24);
	return pName;
}
>> add this at end


Re: [HELP]How to made - Stinged - 23.07.2016

Kaliber's method is much better than that loop method.
You should use that instead.