/fixv command
#1

Just something i saw someone do on here which destroyed the current players vehicle and created a new one and put them into it...

I didnt really like that idea so i did this instead...


SLOTS in my gamemode is defined as 64, the amount the server can hold, change to MAX_PLAYERS if needed...

pawn Код:
new Float:plFixvPos[SLOTS][3];
new Float:plvehAngle[SLOTS];
new fixvInUse;
new plFixV[SLOTS];

forward OnVehicleFix(playerid);
put this under OnGameModeInit
pawn Код:
fixvInUse = -1;
OnPlayerCommandText...
pawn Код:
if(strcmp(cmdtext, "/fixv", true) == 0)
{
    if(fixvInUse == 1)
    {
      SendClientMessage(playerid, COLOR_RED, "Someone is currently using the garage, please wait and try again.");
      return 1;
    }

    if(GetPlayerMoney(playerid) < 2500)
    {
      SendClientMessage(playerid, COLOR_RED, "You must have atleast $10,000 to use this feature!");
      return 1;
    }
       
    if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
    {
      TogglePlayerControllable(playerid, 0);
      fixvInUse = 1;
      SetupVehicleForFix(playerid);
    }
    else
    {
      SendClientMessage(playerid, COLOR_RED, "You Are Not In A Vehicle To Fix!");
    }
    return 1;
}
Somewhere in the script outside of any "public" function...
pawn Код:
stock SetupVehicleForFix(playerid)
{
  new plvehid = GetPlayerVehicleID(playerid);
  GetPlayerPos(playerid,plFixvPos[playerid][0],plFixvPos[playerid][1],plFixvPos[playerid][2]);
  GetVehicleZAngle(plvehid, plvehAngle[playerid]);
  SetVehiclePos(plvehid,1024.7611,-1024.9386,31.7264);
  SetVehicleZAngle(plvehid, 1.9945);
  plFixV[playerid] = 1;
  SetTimerEx("OnVehicleFix", 7000, 0, "i", playerid);
  return 1;
}
pawn Код:
public OnVehicleFix(playerid)
{
    if(plFixV[playerid] == 1)
    {
      SetVehiclePos(GetPlayerVehicleID(playerid), plFixvPos[playerid][0], plFixvPos[playerid][1], plFixvPos[playerid][2]);
      SetVehicleZAngle(GetPlayerVehicleID(playerid), plvehAngle[playerid]);
      plFixV[playerid] = 0;
      fixvInUse = -1;
      plFixvPos[playerid][0] = 0;
      plFixvPos[playerid][1] = 0;
      plFixvPos[playerid][2] = 0;
      plvehAngle[playerid] = 0;
      GivePlayerMoney(playerid, -10000);
      TogglePlayerControllable(playerid, 1);
      SendClientMessage(playerid, COLOR_YELLOW, "You have sucessfully repaired your vehicle!");
    }
    return 1;
}
And that should do it... If theres already one like this on here then this can be removed. I didn't find one and i thought it would come in useful for many servers, especially stunt servers.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)