[HELP] Random Spawn
#1

Hello everyone,

I have one problem, I made a dm zone and in that zone I can't use any other commands but now I don't now how to make if somebody kill somebody in that zone than he spawn on some other spawn in that zone, and when he type /exitdm than he spawn in server spawn, I think you under stand me

Minigun cmd:
Код:
CMD:minigun(playerid,params[])
{
    if(InAfkZone[playerid]==1) return SendClientMessage(playerid, COLOR_ORANGE, "Nemozete koristiti komande u AFK zoni, upisite /back");
	InDmZone[playerid]=1;
	new name[24];
	new string[48];
	SetPlayerPos(playerid, 2555.6736,2844.0222,10.8203);
	GivePlayerWeapon(playerid, 38, 9999);
	GetPlayerName(playerid, name, sizeof(name));
	format(string, sizeof(string), ""COL_RED"%s "COL_LIGHTBLUE">>/minigun<<", name);
	SendClientMessageToAll(COLOR_GREEN, string);
	return 1;
}
exitdm cmd:
Код:
CMD:exitdm(playerid, params[])
{
    if(InAfkZone[playerid]==1) return SendClientMessage(playerid, COLOR_ORANGE, "Nemozete koristiti komande u AFK zoni, upisite /back");
	{
	    InDmZone[playerid] = 0;
	    SpawnPlayer(playerid);
		SetCameraBehindPlayer(playerid);
	    SendClientMessage(playerid, COLOR_KRED, "Napustili ste DM Zonu!");
	}
	return 1;
}
Reply
#2

Quite simple:
pawn Код:
CMD:minigun(playerid,params[])
{
    if(InAfkZone[playerid]==1) return SendClientMessage(playerid, COLOR_ORANGE, "Nemozete koristiti komande u AFK zoni, upisite /back");
    InDmZone[playerid]=1;
    switch(random(...)) //Add inside the 'random' the max amount of spawns (if you have 4 spawns so write '4' there)
    {
        case 0: SetPlayerPos(...); //Add here the data of the first spawn
        case 1: SetPlayerPos(...); //Same as I mentioned above.
        ....//And so on... Example: If you have 4 spawns so you have to write the cases 0-3 since randoms min choose amount is 0 and not 1
    }
    GivePlayerWeapon(playerid, 38, 9999);
    GetPlayerName(playerid, name, sizeof(name));
    new name[24], string[48];
    format(string, sizeof(string), ""COL_RED"%s "COL_LIGHTBLUE">>/minigun<<", name);
    SendClientMessageToAll(COLOR_GREEN, string);
    return 1;
}

CMD:exitdm(playerid, params[])
{
    if(InAfkZone[playerid]==1) return SendClientMessage(playerid, COLOR_ORANGE, "Nemozete koristiti komande u AFK zoni, upisite /back");
    if(InDMZone[playerid] == 0) return SendClientMessage(playerid, 0xFF0000, "ERROR, you aren't even in DM Zone."); //You can translate it into your language
    InDmZone[playerid] = 0;
    SpawnPlayer(playerid);
    SendClientMessage(playerid, COLOR_KRED, "Napustili ste DM Zonu!");
    return 1;
}
Reply
#3

doesn't work, look I need when somebody kill somebody in that aren than player spawns again in that dm zone, understand?
Reply
#4

Oh now I got it:

pawn Код:
OnPlayerSpawn(playerid)
{
    //Add this after all of your spawn infos
    if(InAfkZone[playerid]==1)
    {
        new pname[MAX_PLAYER_NAME], msg[128];
        GetPlayerName(playerid, pname, sizeof(pname));
        switch(random(...)) //Add inside the 'random' the max amount of spawns (if you have 4 spawns so write '4' there)
        {
            case 0: SetPlayerPos(...); //Add here the data of the first spawn
            case 1: SetPlayerPos(...); //Same as I mentioned above.
            ....//And so on... Example: If you have 4 spawns so you have to write the cases 0-3 since randoms min choose amount is 0 and not 1
        }
        format(msg, sizeof(msg), "%s(%d) has been respawned in DM Zone.", pname, playerid);
        SendClientMessageToAll(0xFF6600FF, msg);
    }
}
Reply
#5

pawn Код:
new Float:dm_spawn[4][3]= {
{Coordinits_X,Coordinits_Y,Coordinits_Z},
{Coordinits_X,Coordinits_Y,Coordinits_Z},
{Coordinits_X,Coordinits_Y,Coordinits_Z},
{Coordinits_X,Coordinits_Y,Coordinits_Z}
};
4 Number of cordinits
3 Parвmeters(X,Y,Z);

OnCommand
pawn Код:
SetPlayerPos(playerid, dm_spawn[random(sizeof(dm_spawn))][0],dm_spawn[random(sizeof(dm_spawn))][1],dm_spawn[random(sizeof(dm_spawn))][2]);

abs~
Reply
#6

Quote:
Originally Posted by TheGarfield
Посмотреть сообщение
pawn Код:
new Float:dm_spawn[4][3]= {
{Coordinits_X,Coordinits_Y,Coordinits_Z},
{Coordinits_X,Coordinits_Y,Coordinits_Z},
{Coordinits_X,Coordinits_Y,Coordinits_Z},
{Coordinits_X,Coordinits_Y,Coordinits_Z}
};
4 Number of cordinits
3 Parвmeters(X,Y,Z);

OnCommand
pawn Код:
SetPlayerPos(playerid, dm_spawn[random(sizeof(dm_spawn))][0],dm_spawn[random(sizeof(dm_spawn))][1],dm_spawn[random(sizeof(dm_spawn))][2]);

abs~
that would work but 2+ players can spawn in the same place at the same time !
Reply
#7

But if you are using 2D arrays so you should use it like this:
pawn Код:
enum SpawnInfos
{
    Float:X_POS,
    Float:Y_POS,
    Float:Z_POS,
    Float:Z_ROT,
}

SpawnInfo[][SpawnInfos] = {
{0.0, 0.0, 0.0, 0.0,}, //For the zeros please add correct values to make the player spawn correctly later
{0.0, 0.0, 0.0, 0.0,},
{0.0, 0.0, 0.0, 0.0,},
{0.0, 0.0, 0.0, 0.0,},
//You can add here more if you want..
{0.0, 0.0, 0.0, 0.0,}//<-- Important! In the last 1D array you shouldn't add the comma there excepted you want to add more 1D arrays.
};

//Then later just do
public OnPlayerSpawn(playerid)
{
    //Add this stuff below after those another code you added before.
    new spawnid = random(...); //Add inside the 'random' the max amount of spawns (if you have 5 spawns so write '5' there)
    SetPlayerPos(playerid, SpawnInfo[spawnid][X_POS], SpawnInfo[spawnid][Y_POS], SpawnInfo[spawnid][Z_POS]);
    SetPlayerFacingAngle(playerid, SpawnInfo[spawnid][Z_ROT]);
    return 1;
}
Reply
#8

look, every thing is great I don't care if 2 players will spawn on same place... but I have second problem, when somebody kill me then I don't spawn again in minigun zone (
Reply
#9

Do I have to re-post it? Look at my second or last post here.
Reply
#10

ohh that, but I don't understand this line

Код:
SpawnInfo[][SpawnInfos] = {
{0.0, 0.0, 0.0, 0.0,}, //For the zeros please add correct values to make the player spawn correctly later
{0.0, 0.0, 0.0, 0.0,},
{0.0, 0.0, 0.0, 0.0,},
{0.0, 0.0, 0.0, 0.0,},
//You can add here more if you want..
{0.0, 0.0, 0.0, 0.0,}//<-- Important! In the last 1D array you shouldn't add the comma there excepted you want to add more 1D arrays.
};
I need to set in this zeros my coordinates?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)