SA-MP Forums Archive
[Help]Random Spawn - 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: [Help]Random Spawn (/showthread.php?tid=77834)



[Help]Random Spawn - Marc_307 - 15.05.2009

Hi all.
I wannted to add a Random Spawn in my script. I informed myself at https://sampwiki.blast.hk/wiki/Random. But when i compile it, pawn crashes. What did I do wrong? Please help me.
pawn Код:
#include <a_samp>

new iRandomNumber = random(25);
new Float:RandomSpawn[][4] =
{
  {-2796.9854, 1224.8180, 20.5429, 192.0335},
  {-2454.2170, 503.8759, 30.0790, 267.2932},
  {-2669.7322, -6.0874, 6.1328, 89.8853}
}
 
main()
{
    print("\n----------------------------------");
    print(" Blank Gamemode by your name here");
    print("----------------------------------\n");
}

public OnGameModeInit()
{
    SetGameModeText("Blank Script");
    AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
    return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
    SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
    SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
    return 1;
}

public OnPlayerSpawn(playerid)
{
  new iRandom = random(sizeof(RandomSpawn));
  //SetPlayerPos to the random spawn information
  SetPlayerPos(playerid, RandomSpawn[iRandom][0], RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
  //SetPlayerFacingAngle to the random facing angle information
  SetPlayerFacingAngle(playerid, RandomSpawn[iRandom][3]);
  return 1;
}



Re: [Help]Random Spawn - [HiC]TheKiller - 15.05.2009

You are missing a bracket "{" or "}" somewhere in your script.


Re: [Help]Random Spawn - Cabby - 15.05.2009

Made it more easy to look at
Код:
#include <a_samp>

new iRandomNumber = random(25);
new Float:RandomSpawn[][4] =
{
  {-2796.9854, 1224.8180, 20.5429, 192.0335},
  {-2454.2170, 503.8759, 30.0790, 267.2932},
  {-2669.7322, -6.0874, 6.1328, 89.8853}
}
 
main()
{
	print("\n----------------------------------");
	print(" Blank Gamemode by your name here");
	print("----------------------------------\n");
}

public OnGameModeInit()
{
	SetGameModeText("Blank Script");
	AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
	return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
	SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
	SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
	return 1;
}

public OnPlayerSpawn(playerid)
{
  new iRandom = random(sizeof(RandomSpawn));
  SetPlayerPos(playerid, RandomSpawn[iRandom][0], RandomSpawn[iRandom][1],RandomSpawn[iRandom][2]);
  SetPlayerFacingAngle(playerid, RandomSpawn[iRandom][3]);
  return 1;
}



Re: [Help]Random Spawn - Marc_307 - 15.05.2009

Quote:

You are missing a bracket "{" or "}" somewhere in your script.

Where am I missing a bracket "{" or "}" im my script?


Re: [Help]Random Spawn - Nero_3D - 15.05.2009

its [pawn][/pawn] not [pwn][/pwn]

pawn Код:
#include <a_samp>

//new iRandomNumber = random(25); //you can create a variable global but you cant use a funtion global
new Float:RandomSpawn[][4] =
{
  {-2796.9854, 1224.8180, 20.5429, 192.0335},
  {-2454.2170, 503.8759, 30.0790, 267.2932},
  {-2669.7322, -6.0874, 6.1328, 89.8853}
}; //you forgot here a semicolon

//rest of the code is ok



Re: [Help]Random Spawn - Ignas1337 - 15.05.2009

i was just about to tell... but i just saw it was solved already


Re: [Help]Random Spawn - Marc_307 - 15.05.2009

Quote:

its not [pwn][/pwn]

thx, know I know it better

And big thanks again for your help. Now it works.


Re: [Help]Random Spawn - Ignas1337 - 15.05.2009

♣ ⓐⓢⓢ says no problem
lol