new PlayerCount;
CMD:joinevent(playerid,params[])
{
// some codes ...
if(PlayerCount == 20) return SendClientMessage(playerid,-1,"event is full");
PlayerCount++;
return 1;
}
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.
};
new Random = random(sizeof(Spawns));
SetPlayerPos(playerid,Spawns[Random][0],Spawns[Random][1],Spawns[Random][2]);
SetPlayerFacingAngle(playerid,Spawns[Random][3]);
mhm try to check their positions
and make 20 players max per event 20 spawn points |
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;
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;
}
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.
}
}
}
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;
}
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" |
SetPlayerPos(playerid,Spawns[PlayerCount][0],etc...);