SA-MP Forums Archive
Ramp spawning theortetical stuff :/ - 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: Ramp spawning theortetical stuff :/ (/showthread.php?tid=94840)



Ramp spawning theortetical stuff :/ - Frankylez - 01.09.2009

Hi!

So I have this little ramp function. It checks whether player ramp is used or not, then spawns deciding on the ramp slot status.
pawn Код:
if(togRamp[playerid] == true)
{
  if(IsPlayerInAnyVehicle(playerid))
  {
    if(newkeys & rampKey[playerid])
    {
      if(playerRampUsed[playerid][0] == 0)
      {
        CreatePlayerRamp(playerid, 0);
      }
      else
      {
        if(playerRampUsed[playerid][1] == 0)
        {
          CreatePlayerRamp(playerid, 1);
        }
        else
        {
          if(playerRampUsed[playerid][2] == 0)
          {
            CreatePlayerRamp(playerid, 2);
          }
          else
          {
            CreatePlayerRamp(playerid, 0);
          }
        }
      }
    }
  }
}
But what happens is that:
Player presses their ramp key, ramp spawns (player ramp slot 0)...
Player presses their ramp key, ramp spawns (player ramp slot 1)...
Player presses their ramp key, ramp spawns (player ramp slot 2)...
Player presses their ramp key, ramp spawns (player ramp slot 2 overriding 2)...
What I want it to do while ramp slots 0, 1 and 2 are full is to override ramp slot 0!
I don't know what I've done wrong, but look at my CreatePlayerRamp function:
pawn Код:
CreatePlayerRamp(playerid, rampslot)
{
  if(playerRampUsed[playerid][rampslot] == rampslot) destroyPlayerRamp(playerid, rampslot);
         
  GetPlayerPos(playerid, POS[0], POS[1], POS[2]);
  playerRamp[playerid][rampslot] = CreatePlayerObject(playerid, 1632, POS[0], POS[1], POS[2] - 0.4, 0.0, 0.0, GetPosInFrontOfPlayer(playerid, POS[0], POS[1], GetRampDistance(playerid)));
  playerRampUsed[playerid][rampslot] = 1;
  KillTimer(playerRampDestroy[playerid][rampslot]);
  playerRampDestroy[playerid][rampslot] = SetTimerEx("destroyPlayerRamp", 1500, false, "id", playerid, rampslot);
}