Random spawns.
#1

I want to make a command that spawns randomly, how can i make it?
Reply
#2

Put this the rest of your "new"
pawn Code:
new Float:RandomSpawns[4][3] = {
{1253.6213,368.9244,19.5614}, //Change if you wish to.
{1263.1244,369.7004,19.5547}, //Change if you wish to.
{1246.1509,368.8576,19.5547}, //Change if you wish to.
{1256.1157,364.1463,19.5614} //Change if you wish to.
};

Put this under OnPlayerCommandText.

pawn Code:
if(strcmp(cmdtext, "/rspawn", true) == 0) // Change if you wish to.
    {
    new rand = random(sizeof(RandomSpawns));
    SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);
}
Reply
#3

Quote:
Originally Posted by Stah™
Spawns what randomly?
Oh yea, sorry XD, a person.
Reply
#4

Quote:
Originally Posted by Stah™
pawn Code:
new Float:RandomSpawns[4][3] = {
{1253.6213,368.9244,19.5614}, //Change if you wish to.
{1263.1244,369.7004,19.5547}, //Change if you wish to.
{1246.1509,368.8576,19.5547}, //Change if you wish to.
{1256.1157,364.1463,19.5614} //Change if you wish to.
};
pawn Code:
if(strcmp(cmdtext, "/rspawn", true) == 0)
    {
    new rand = random(sizeof(RandomSpawns));
    SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);
}
Thanks!
Reply
#5

Oh, I forgot, also I need to give him a weapon, example, he tipes /dm and gives weapons and random spawns.
Reply
#6

Quote:
Originally Posted by Fedee!
Oh, I forgot, also I need to give him a weapon, example, he tipes /dm and gives weapons and random spawns.
add weapon thing to here:

Code:
if(strcmp(cmdtext, "/rspawn", true) == 0)
    {
	new rand = random(sizeof(RandomSpawns));
	SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);
    SafeGivePlayerWeapon(playerid, 3, 1);
    SafeGivePlayerWeapon(playerid, 3, 1);
}
3 means weapon id and that 1 is bullet ammount.
Reply
#7

Quote:
Originally Posted by Peep
Quote:
Originally Posted by Fedee!
Oh, I forgot, also I need to give him a weapon, example, he tipes /dm and gives weapons and random spawns.
add weapon thing to here:

Code:
if(strcmp(cmdtext, "/rspawn", true) == 0)
    {
	new rand = random(sizeof(RandomSpawns));
	SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);
    SafeGivePlayerWeapon(playerid, 3, 1);
    SafeGivePlayerWeapon(playerid, 3, 1);
}
3 means weapon id and that 1 is bullet ammount.
Thanks!

**EDIT**

Got this error:
Quote:

C:\Documents and Settings\Feche!\Escritorio\Server SAMP\gamemodes\freeroam.pwn(1167) : error 017: undefined symbol "SafeGivePlayerWeapon"

Reply
#8

Code:
if(strcmp(cmdtext, "/rspawn", true) == 0)
    {
	new rand = random(sizeof(RandomSpawns));
	SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);
    GivePlayerWeapon(playerid, 3, 1);
}
Reply
#9

Quote:
Originally Posted by timmehhh
Code:
if(strcmp(cmdtext, "/rspawn", true) == 0)
    {
	new rand = random(sizeof(RandomSpawns));
	SetPlayerPos(playerid, RandomSpawns[rand][0], RandomSpawns[rand][1], RandomSpawns[rand][2]);
    GivePlayerWeapon(playerid, 3, 1);
}
Thanks! Now works ^^
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)