Random spawn
#1

Hey guys. I made little DM zone and I want players to spawn randomly on several positions in that DM zone. How can i do that?? Here are the coords
Код:
            {-409.1236, 2244.5474, 42.4297}
	    {-408.6208, 2224.4314, 42.4297}
	    {-419.5130, 2229.0693, 42.4297}
	    {-370.0843, 2242.7195, 45.8725}
	    {-355.8813, 2241.0496, 45.5545}
	    {-374.6754, 2232.2986, 42.4844}
	    {-394.5614, 2259.2595, 42.1517}
Reply
#2

What's the full code for it? The coords aren't really helpful. Although something similar to this should suffice;
pawn Код:
public OnPlayerSpawn(playerid) {
new randomcoords = random(sizeof(variablename));
SetPlayerPos(playerid, variablename[randomcoords][0], variablename[randomcoords][1], variablename[randomcoords][2]);
return 1;
}
Reply
#3

There is no full code. This is DM mode that I am making. When connect player spawn in city and that is fine. But when he types /dm i want him to spawn on those coord i posted there. And i want every player to spawn on diferente coords (looping trought those i posted). Hope you understand
Reply
#4

I don't mean anything by this, but is it hard to ****** something before posting?

https://sampforum.blast.hk/showthread.php?tid=162488
This tutorial explains it very well.
Reply
#5

Quote:
Originally Posted by Stinged
Посмотреть сообщение
I don't mean anything by this, but is it hard to ****** something before posting?

https://sampforum.blast.hk/showthread.php?tid=162488
This tutorial explains it very well.
First read what i wanted and then post answers. I tried that tutorial before posting this thread. And i got tons of errors and warns so....
Reply
#6

Quote:
Originally Posted by Micko123
Посмотреть сообщение
There is no full code. This is DM mode that I am making. When connect player spawn in city and that is fine. But when he types /dm i want him to spawn on those coord i posted there. And i want every player to spawn on diferente coords (looping trought those i posted). Hope you understand
Alright, well let me edit my code for you.
pawn Код:
new Float:DMSpawn[][] = {
            {-409.1236, 2244.5474, 42.4297},
        {-408.6208, 2224.4314, 42.4297},
        {-419.5130, 2229.0693, 42.4297},
        {-370.0843, 2242.7195, 45.8725},
        {-355.8813, 2241.0496, 45.5545},
        {-374.6754, 2232.2986, 42.4844},
        {-394.5614, 2259.2595, 42.1517}
};

public OnPlayerSpawn(playerid) {
        new randomcoords = random(sizeof(DMSpawn));
        SetPlayerPos(playerid, DMSpawn[randomcoords][0], DMSpawn[randomcoords][1], DMSpawn[randomcoords][2]);
        return 1;
}
This should work for you.
Reply
#7

But what should i put under
Код:
CMD:dm(playerid, params[])
Cus i am making /dm with ZCMD
Reply
#8

Just simple add the code from OnPlayerSpawn to the command, like so;
pawn Код:
CMD:dm(playerid, params[]) {
        new randomcoords = random(sizeof(DMSpawn));
        SetPlayerPos(playerid, DMSpawn[randomcoords][0], DMSpawn[randomcoords][1], DMSpawn[randomcoords][2]);
            return 1;
}
I'm sure you can add the messages & checks to the command yourself.
Reply
#9

Thank you worked.
And one more thing(two ) How can i make /leavedm command and how can i make when player dies in DM zone he stays in DM zone (unless he types /leavedm) Thank you man [REP +]
Reply
#10

That'd be a simple variable like,
pawn Код:
new PlayerJoinedDMZone[MAX_PLAYERS];
When a player types the /dm command add in this;
pawn Код:
PlayerJoinedDMZone[playerid] = 1;
So when he dies he'll be spawned back inside the DM zone;
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) {
if(PlayerJoinedDMZone[playerid] == 1) {
        new randomcoords = random(sizeof(DMSpawn));
        SetPlayerPos(playerid, DMSpawn[randomcoords][0], DMSpawn[randomcoords][1], DMSpawn[randomcoords][2]);
}
return 1;
}
Then simply, the /leavedm command would be something like this;
pawn Код:
CMD:leavedm(playerid, params[]) {
        PlayerJoinedDMZone[playerid] = 0;
        SendClientMessage(playerid, -1, "You've left the DM zone.");
        return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)