Randomish Teleport?
#1

So im making a Free Roam and i want to type /dm And It will bring me to a Deathmatch Area(area 51). But I Want it to Teleport Me To More Than just one Teleport Place While type /dm.
Any Help?
Reply
#2

pawn Код:
new Float:gRandomSpawns [MAX_SPAWNS] [4] = {
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
....
{x,y,z},
{x,y,z}
};

for(new i;i<MAX_PLAYERS;i++)

SetPlayerPos(playerid,gRandomSpawns [i] [1],gRandomSpawns [i] [2],gRandomSpawns [i] [3]}
Should work. I haven't scripted something with Random spawns for long time so this was something I have remembered.
Reply
#3

Yea i did the Same thing that you suggested i thank you but i did already figure it out. But Ill Give you Rep
Reply
#4

Quote:
Originally Posted by [MG]Dimi
Посмотреть сообщение
pawn Код:
new Float:gRandomSpawns [MAX_SPAWNS] [4] = {
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
....
{x,y,z},
{x,y,z}
};

for(new i;i<MAX_PLAYERS;i++)

SetPlayerPos(playerid,gRandomSpawns [i] [1],gRandomSpawns [i] [2],gRandomSpawns [i] [3]}
Should work. I haven't scripted something with Random spawns for long time so this was something I have remembered.
this code don't is random.
the float starter of 0.

Correct:
pawn Код:
new Float:gRandomSpawns [MAX_SPAWNS] [4] = {
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
{x,y,z},
....
{x,y,z},
{x,y,z}
};

SetPlayerPos(playerid,gRandomSpawns [random(sizeof(Float:gRandomSpawns ))] [0],gRandomSpawns random(sizeof(Float:gRandomSpawns ))] [1],gRandomSpawns [random(sizeof(Float:gRandomSpawns ))] [2]}
Reply
#5

This Works Fine,

Код:
new Float:RandomSpawn[][4] =
{
    {283.3869, 1805.9667, 17.6406},
    {217.2084, 1852.7458, 12.7484},
    {248.5981, 1858.0115, 14.0840}
};

public OnPlayerCommandText(playerid, cmdtext[])
	{
	if (strcmp("/dm", cmdtext, true, 10) == 0)
	{
		new rand = random(sizeof(RandomSpawn));
    	SetPlayerPos(playerid, RandomSpawn[rand][0], RandomSpawn[rand][1],RandomSpawn[rand][2]);
		GivePlayerWeapon(playerid, 31, 99999);
		GivePlayerWeapon(playerid, 26, 99999);
		GivePlayerWeapon(playerid, 34, 99999);
		SetTimer("time", 900, 1);
		new name[MAX_PLAYER_NAME], string[44];
    	GetPlayerName(playerid, name, sizeof(name));
    	format(string, sizeof(string), "%s has joined the DM!",name);
    	SendClientMessageToAll(0xFFFF00AA, string);
    	GameTextForPlayer(playerid, "~y~Welcome to the ~r~DM ~y~zone! Type: /leavedm to leave the DM!", 3000, 3);
		return 1;
 	}
	if (strcmp(cmdtext, "/leavedm", true) == 0) {
 {
 		new name[MAX_PLAYER_NAME], string[44];
    	GetPlayerName(playerid, name, sizeof(name));
    	format(string, sizeof(string), "%s has Left the DM!",name);
    	SendClientMessageToAll(0xFFFF00AA, string);
 		SetPlayerPos(playerid,2799.8398,-2547.7798,13.6282);
 		}
		return 1;
Reply
#6

I don't understand one thing: Why are you using 2 times
pawn Код:
new name[MAX_PLAYER_NAME], string[44];
GetPlayerName(playerid,name,sizeof(name));
?
Use this one:
PHP код:
public OnPlayerConnect(playerid)
{
    new 
name[MAX_PLAYER_NAME] = GetPlayerName(playerid,name,sizeof(name));    
    return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)