SA-MP Forums Archive
Random spawns. - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Random spawns. (/showthread.php?tid=120745)



Random spawns. - Fedee! - 12.01.2010

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


Re: Random spawns. - Stah - 12.01.2010

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]);
}



Re: Random spawns. - Fedee! - 12.01.2010

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


Re: Random spawns. - Fedee! - 12.01.2010

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!


Re: Random spawns. - Fedee! - 12.01.2010

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



Re: Random spawns. - Peep - 12.01.2010

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.


Re: Random spawns. - Fedee! - 12.01.2010

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"




Re: Random spawns. - timmehhh - 12.01.2010

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);
}



Re: Random spawns. - Fedee! - 12.01.2010

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 ^^