rendered paste body//------------------------------------------------------------------------------
//
// Xoomer miniMission Filter Script v1.0
// Designed for SA-MP v0.2.1
//
// Created by zeruel_angel
//
//------------------------------------------------------------------------------
#include <a_samp>
enum posicion
{
Float:Size,
Float:X,
Float:Y,
Float:Z
}
#define BONUS 500
#define MAX_CASH 2000
#define MIN_CASH 1000
#define MAX_ESTACIONES 100
new EDS[MAX_ESTACIONES][posicion];
new archFuelDestinations[]="FuelDestinations.txt";
new playerInMiniMission[MAX_PLAYERS];
new CantEstaciones;
new contador[MAX_PLAYERS];
new dest[MAX_PLAYERS];
new avisado1[MAX_PLAYERS];
new linea[255];
forward terminarMission(playerid);
//------------------------------------------------------------------------------------------------------
public OnFilterScriptInit()
{
print("\n XOOMER Filter Script v1.0 Loading...\n***********************************\n (Zeruel_Angel)\n");
//cargo los checkpoints desde el archivo
new File:file1;
new j=0;
new idx;
file1 = fopen(archFuelDestinations,io_readwrite);
while ((fread(file1,linea,sizeof(linea),false))&&(j<MAX_ESTACIONES))
{
idx = 0;
EDS[j][Size] = floatstr(strtok(linea,idx));
EDS[j][X] = floatstr(strtok(linea,idx));
EDS[j][Y] = floatstr(strtok(linea,idx));
EDS[j][Z] = floatstr(strtok(linea,idx));
j++;
}
fclose(file1);
CantEstaciones=j;
format(linea,sizeof(linea),"Cantidad total de Destinos cargados: %d", CantEstaciones);
print(linea);
for (new i=0;i<MAX_PLAYERS;i++)
{
avisado1[i]=-1;
}
print("Xoomer Filter Script fully Loaded\n**********************************\n\n");
}
//------------------------------------------------------------------------------------------------------
public OnFilterScriptExit()
{
print("\n XOOMER Script UnLoaded\n********************************************\n\n");
return 1;
}
//------------------------------------------------------------------------------------------------------
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}
//------------------------------------------------------------------------------------------------------
public terminarMission(playerid)
{
GameTextForPlayer(playerid,"~r~Xoomer ~n~ ~w~MiniMision ~n~~w~cancelled",3000,4);
DestroyVehicle(playerInMiniMission[playerid]);
playerInMiniMission[playerid]=0;
avisado1[playerid]=-1;
DisablePlayerRaceCheckpoint(playerid);
contador[playerid]=0;
return 1;
}
//------------------------------------------------------------------------------------------------------
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate==PLAYER_STATE_DRIVER)
{
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 514)
{
if (avisado1[playerid]==-1)
{
GameTextForPlayer(playerid,"~w~Press ~b~Buttom 2~n~~w~to start ~r~Xoomer~n~~w~Minimission",3000,5);//SetTimerEx("MandarMensaje",5500,0,"%d",playerid);
}
else
{
KillTimer(avisado1[playerid]);
avisado1[playerid]=-1;
}
}
}
if (newstate==PLAYER_STATE_ONFOOT)
{
if ((playerInMiniMission[playerid]!=0)&&(avisado1[playerid]==-1))
{
GameTextForPlayer(playerid,"~You have ~r~10 sec ~n~~w~ to get a Truck",3000,4);
avisado1[playerid]=SetTimerEx("terminarMission",10000,0,"%d",playerid);
}
}
return 1;
}
//------------------------------------------------------------------------------------------------------
ProximaEstacion(playerid)
{
new index = dest[playerid];
DisablePlayerRaceCheckpoint(playerid);
playerInMiniMission[playerid]=CreateVehicle(584,0.0,0.0,0.0,0.0,0,1,-1);
AttachTrailerToVehicle(playerInMiniMission[playerid],GetPlayerVehicleID(playerid));
SetPlayerRaceCheckpoint(playerid,0,EDS[index][X],EDS[index][Y],EDS[index][Z],278.8607,1420.3838,11.0867,EDS[index][Size]);
//FALTA LO DEL TRAILER
return 1;
}
//------------------------------------------------------------------------------------------------------
Refineria(playerid)
{
DisablePlayerRaceCheckpoint(playerid);
new index = random(CantEstaciones);
dest[playerid]=index;
SetPlayerRaceCheckpoint(playerid,0,278.8607,1420.3838,11.0867,EDS[index][X],EDS[index][Y],EDS[index][Z],EDS[index][Size]);
return 1;
}
//------------------------------------------------------------------------------------------------------
MissionIni(playerid)
{
GameTextForPlayer(playerid,"~r~Xoomer ~w~MiniMision ~w~starts!~n~ go to the ~n~~r~Refinery",3000,4);
Refineria(playerid);
playerInMiniMission[playerid]=-1;
return 1;
}
//------------------------------------------------------------------------------------------------------
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if ((newkeys==KEY_SUBMISSION)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
{
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 514)
{
if (playerInMiniMission[playerid]==0)
{
MissionIni(playerid);
}
else
{
terminarMission(playerid);
}
}
}
}
//------------------------------------------------------------------------------------------------------
public OnPlayerEnterRaceCheckpoint(playerid)
{
if (playerInMiniMission[playerid]==-1)
{
if (IsPlayerInAnyVehicle(playerid))
{
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 514)
{
if (IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
{
DetachTrailerFromVehicle(GetPlayerVehicleID(playerid));
}
GameTextForPlayer(playerid,"~w~The ~r~tank ~w~its filled.~n~take it to the ~r~gas station",3000,4);
ProximaEstacion(playerid);
}
else
{
GameTextForPlayer(playerid,"~w~You need a ~r~truck",3000,4);
}
}
else
{
GameTextForPlayer(playerid,"~w~You need a ~r~truck",3000,4);
}
return 1;
}
if (playerInMiniMission[playerid]!=0)
{
if (IsPlayerInAnyVehicle(playerid))
{
if ((GetVehicleModel(GetPlayerVehicleID(playerid)) == 514)
&&(IsTrailerAttachedToVehicle(GetPlayerVehicleID(playerid)))
&&(GetVehicleTrailer(GetPlayerVehicleID(playerid))==playerInMiniMission[playerid]))
{
contador[playerid]++;
new cash=(random(MAX_CASH-MIN_CASH)+MIN_CASH);
GivePlayerMoney(playerid,cash);
DestroyVehicle(playerInMiniMission[playerid]);
playerInMiniMission[playerid]=-1;
Refineria(playerid);
if ((((contador[playerid]/5)*5)==contador[playerid])&&(contador[playerid]!=0))
{
new string[255];
format(string,sizeof(string),"You get a ~r~BONUS ~w~ every 5 times!.~n~You made %d delivers, your bonus is ~n~~b~$%d",contador[playerid],contador[playerid]*BONUS);
GameTextForPlayer(playerid,string,3000,3);
}
else
{
GameTextForPlayer(playerid,"~w~Fuel delivered! here is your cash!. ~n~Go back to the ~r~refinery",5000,3);
}
}
}
}
return 1;
}
//------------------------------------------------------------------------------------------------------
public OnPlayerDisconnect(playerid)
{
if (playerInMiniMission[playerid]!=0)
{
terminarMission(playerid);
}
return 1;
}
//------------------------------------------------------------------------------------------------------
public OnGameModeInit( )
{
ShowPlayerMarkers( 0 );
}