Player Count-Pos for each player-countdown in textdraw-last man standing.. :p
#1

ok so hey ,
i want to create a event,so i've created the map,now i need some help guys
first,for player count,i want to make maximum players in event:20,i want to make sure from codes,something like this?:
PHP код:
new PlayerCount;
CMD:joinevent(playerid,params[])
{
// some codes ...
if(PlayerCount == 20) return SendClientMessage(playerid,-1,"event is full");
PlayerCount++;
return 
1;

is that exact or?,,,
ok so second,i want to choose a position for each player,i don't want to make them spawn in the same position,and here i don't know how xD,i already took 20 different positions,just need codes..
and for countdown,i want to set a timer,and put it in a textdraw,how to set the timer exactly?
and i want to know last man standing in the event,its a DM event,if(PlayerCount == 1) but how to get his name,and where to put them..
thanks in advance
Reply
#2

pawn Код:
new Float:Spawns[][]=
{
{x,y,z,angle},
{x,y,z,angle},
{x,y,z,angle},
{x,y,z,angle},
{x,y,z,angle},
{x,y,z,angle},
{x,y,z,angle} // <--- Last one must not have a comma.
};
To spawn somebody randomly:
pawn Код:
new Random = random(sizeof(Spawns));
SetPlayerPos(playerid,Spawns[Random][0],Spawns[Random][1],Spawns[Random][2]);
SetPlayerFacingAngle(playerid,Spawns[Random][3]);
Read about timers here:
https://sampforum.blast.hk/showthread.php?tid=133801
Reply
#3

Oh,i know how to spawn players rondomly,but if its 20 spawns,so random[20] and player will have a big chance to spawn on another one,understand?
And for timer,i want a countdown,so players can see time,like:"time left:10 seconds"
Reply
#4

mhm try to check their positions
and make 20 players max per event
20 spawn points
Reply
#5

Quote:
Originally Posted by Toxik
Посмотреть сообщение
mhm try to check their positions
and make 20 players max per event
20 spawn points
Lol?read again please
Reply
#6

Hello!

Well there are any problems between us, but I can see over them.
So. I want to help you.

Quote:
Originally Posted by Roberto80
Посмотреть сообщение
is that exact or?,,,
Yes, it is correct.

Your second problem:
You can do this:
PHP код:
new Float:RandomSpawns[][4]
{
    {
1234.1234,1234.1234,1234.1234,90.0},
    {
1236.1236,1236.1236,1236.1236,90.0}
};
new 
bool:SpawnsUsed[sizeof(RandomSpawns)];
//Where you set the players position:
try_again:
new 
rand random(sizeof(RandomSpawns));
if(
SpawnsUsed[rand] == true)
{
    do 
try_again;
}
SetPlayerPos(playerid,RandomSpawns[rand][0],RandomSpawns[rand][1],RandomSpawns[rand][2]);
SpawnsUsed[rand] = true
Your third problem:
PHP код:
new EventTimer;
//You set the time:
EventTimer 20;
//Where you start the timer:
SetTimer("Event_Timer",1000,1);
forward Event_Timer();
public 
Event_Timer()
{
    if(
Event_Timer == 0)
    {
        
//Start the Timer
        
return 1;
    }
    
Event_Timer --;
    new 
string[64];
    
format(string,sizeof string,"time left: %i seconds",Event_Timer);
    
//Update the textdraw.
    
return 1;

Your last problem:
PHP код:
new PlayerCount_Event[MAX_PLAYERS];
CMD:joinevent(playerid,params[])
{
    
// some codes ...
    
if(PlayerCount == 20) return SendClientMessage(playerid,-1,"event is full");
    
PlayerCount++;
    
PlayerCount_Event[playerid] = PlayerCount;
    return 
1;
}
new 
name[MAX_PLAYER_NAME];
for(new 
i;i<MAX_PLAYERS;i++)
{
    if(
GetPlayerName(playerid,name,sizeof name))
    {
        if(
PlayerCount_Event[i] > 0)
        {
            
//Player (i) is in the Event.
        
}
    }

Reply
#7

Problems? Haven't saw before x)
Thanks!!! I will try them
Reply
#8

I would do it like this:
pawn Код:
new PlayerCount;
new bool:PlayerAtEvent[MAX_PLAYERS];

// in the command for creating an event, PlayerCount is set to 0

CMD:joinevent(playerid)
{
    if(PlayerCount >= 20) return 1;
    // ....
    PlayerCount ++;
    // Let's say you have set a default position, i.e. 1200, -450, 1900
    SetPlayerPos(playerid, 1200 + random(10), -450 + random(10), 1900); // you'll get a random value for x and y coordinates
    PlayerAtEvent[playerid] = true;
    return 1;
}

new CountdownTimer;
new Count; // set it to i.e. 20
SetTimer("Countdown", 1000, true);
forward public Countdown();
public Countdown()
{
    Count --;
    // update textdraw string
    if(!Count)
    {
        KillTimer(CountdownTimer);
        // unfreeze the players, etc..
    }
    return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
    new n;
    foreach(Player, i)
    {
        if(PlayerAtEvent[i] == true)
            n ++;
    }
    if(n == 1) // if the amount of players on the event is 1, killer is the only alive player
    {
        // end the event etc.
    }
    return 1;
}
You could also create an array with spawning locations and then get a random index for the array
Reply
#9

Quote:
Originally Posted by Roberto80
Посмотреть сообщение
Oh,i know how to spawn players rondomly,but if its 20 spawns,so random[20] and player will have a big chance to spawn on another one,understand?
And for timer,i want a countdown,so players can see time,like:"time left:10 seconds"
Well you answered your own question, use PlayerCount variable for this.

Assuming you have 20 players max in an event, that's 20 spawns.

Starts from 0.
Player 1 /event's
That's 1.
SetPlayerPos to the first field.
pawn Код:
SetPlayerPos(playerid,Spawns[PlayerCount][0],etc...);
First player types /event will always spawn in this position, second player will spawn at the second position and so on...
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)