SA-MP Forums Archive
Spawn menu - 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: Spawn menu (/showthread.php?tid=130764)



Spawn menu - security - 28.02.2010

I'm makeing a /test menu, if you say /test a dialog will come up with 2 choises TestMenu1 and TestMenu2, i got the whole stuff but i have one problem, how can i make so that the cars will spawn close to the player? example:

Код:
  if(dialogid == 2 && response)
  {
    switch(listitem)
    {
      case 0:
      {
				CreateVehicle(515, ??, ??, ??, ??, 670, 60, 12000);
      }
      case 1:
      {
				CreateVehicle(515, ??, ??, ??, ??, 670, 60, 12000);
      }
      case 2:
      {
				CreateVehicle(515, ??, ??, ??, ??, 670, 60, 12000);
      }
    }
  }
I got everything so far good i think, but those ?? must become so that they spawn close to the player. What must i add? i cant find it.


Re: Spawn menu - [HiC]TheKiller - 28.02.2010

https://sampwiki.blast.hk/wiki/GetPlayerPos


Re: Spawn menu - Norck - 28.02.2010

Try
Код:
if(dialogid == 2 && response)
  {
    new Float:x, Float:y, Float:z, Float:f;
    GetPlayerPos(playerid,x,y,z); 
    GetPlayerFacingAngle(playerid,f);
    switch(listitem)
    {
      case 0:
      {
				CreateVehicle(515, x+1, y, z, f, 670, 60, 12000);
      }
      case 1:
      {
				CreateVehicle(515, x+1, y, z, f, 670, 60, 12000);
      }
      case 2:
      {
				CreateVehicle(515, x+1, y, z, f, 670, 60, 12000);
      }
    }
  }



Re: Spawn menu - Gozerr - 28.02.2010

Quote:
Originally Posted by security
I'm makeing a /test menu, if you say /test a dialog will come up with 2 choises TestMenu1 and TestMenu2, i got the whole stuff but i have one problem, how can i make so that the cars will spawn close to the player? example:

Код:
  if(dialogid == 2 && response)
  {
    switch(listitem)
    {
      case 0:
      {
				CreateVehicle(515, ??, ??, ??, ??, 670, 60, 12000);
      }
      case 1:
      {
				CreateVehicle(515, ??, ??, ??, ??, 670, 60, 12000);
      }
      case 2:
      {
				CreateVehicle(515, ??, ??, ??, ??, 670, 60, 12000);
      }
    }
  }
I got everything so far good i think, but those ?? must become so that they spawn close to the player. What must i add? i cant find it.
pawn Код:
forward Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance);

new Float:x, Float:y, Float:z, Float:a;
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
z + 2.0;
a + 90;

  if(dialogid == 2 && response)
  {
    switch(listitem)
    {
      case 0:
      {
                CreateVehicle(515, x, y, z, a, 670, 60, 12000);
      }
      case 1:
      {
                CreateVehicle(515, x, y, z, a, 670, 60, 12000);
      }
      case 2:
      {
                CreateVehicle(515, x, y, z, a, 670, 60, 12000);
      }
    }
  }

Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
else GetPlayerFacingAngle(playerid, a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
 return a;
}



Re: Spawn menu - security - 28.02.2010

Quote:
Originally Posted by Gozerr
pawn Код:
forward Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance);

new Float:x, Float:y, Float:z, Float:a;
GetPlayerFacingAngle(playerid, a);
GetPlayerPos(playerid, x, y, z);
GetXYInFrontOfPlayer(playerid, x, y, 5.0);
z + 2.0;
a + 90;

  if(dialogid == 2 && response)
  {
    switch(listitem)
    {
      case 0:
      {
                CreateVehicle(515, x, y, z, a, 670, 60, 12000);
      }
      case 1:
      {
                CreateVehicle(515, x, y, z, a, 670, 60, 12000);
      }
      case 2:
      {
                CreateVehicle(515, x, y, z, a, 670, 60, 12000);
      }
    }
  }

Float:GetXYInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
if (IsPlayerInAnyVehicle(playerid)) GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
else GetPlayerFacingAngle(playerid, a);
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
 return a;

}
I cant let it work? i got already 2 differend, but i want to try 3 kind if possbile how can i add this one