19.09.2011, 22:23
(
Last edited by Medardo4Life; 20/09/2011 at 05:57 AM.
)
pawn Code:
//------------------------------------------------------------------------------
//
// PizzaBoy miniMission Filter Script v1.0
// Designed for SA-MP v0.2.1
//
// Created by zeruel_angel
//
//------------------------------------------------------------------------------
#define BONUS 2500
#include <a_samp>
enum posicion{
Float:X,
Float:Y,
Float:Z
}
#define BONUS 2500
#define MAX_CASH 500
#define MIN_CASH 100
new Destinos[100][posicion];
new Pizzerias[20][posicion];
new archDestinos[]="PizzaBoy1.txt";
new archPizzerias[]="PizzaBoy2.txt";
new contador[MAX_PLAYERS];
new playerInMiniMission[MAX_PLAYERS];
new avisado[MAX_PLAYERS];
new cantidadDestinos;
new cantidadPizzerias;
forward terminarMission(playerid);
public OnFilterScriptInit()
{
print("\nPIZZABOY Filter Script v1.0 Loading...\n******************************\n (Zeruel_Angel)\n");
new File:filePizza;
new lineaPizza[255];
filePizza = fopen(archDestinos,io_readwrite);
new j=0;
new idx;
while ((fread(filePizza,lineaPizza,sizeof(lineaPizza),false))&&(j<25))
{
idx = 0;
Destinos[j][X] = floatstr(strtok(lineaPizza,idx));
Destinos[j][Y] = floatstr(strtok(lineaPizza,idx));
Destinos[j][Z] = floatstr(strtok(lineaPizza,idx));
j++;
}
cantidadDestinos=j;
fclose(filePizza);
format(lineaPizza,sizeof(lineaPizza),"Total destinations loaded: %d", cantidadDestinos);
print(lineaPizza);
filePizza = fopen(archPizzerias,io_readwrite);
j=0;
while ((fread(filePizza,lineaPizza,sizeof(lineaPizza),false))&&(j<25))
{
idx = 0;
Pizzerias[j][X] = floatstr(strtok(lineaPizza,idx));
Pizzerias[j][Y] = floatstr(strtok(lineaPizza,idx));
Pizzerias[j][Z] = floatstr(strtok(lineaPizza,idx));
j++;
}
cantidadPizzerias=j;
fclose(filePizza);
format(lineaPizza,sizeof(lineaPizza),"Total pizzeria loaded: %d", cantidadPizzerias);
print(lineaPizza);
for (new i=0;i<MAX_PLAYERS;i++)
{
playerInMiniMission[i]=-1;
avisado[i]=-1;
}
print("PIZZABOY Filter Script fully Loaded\n**********************************\n\n");
}
public OnFilterScriptExit()
{
print("\n**********************\n*PizzaBoy Script UnLoaded*\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~PizzaBoy ~n~ ~w~SideJob ~n~ ~w~cancelled",3000,4);
playerInMiniMission[playerid]=-1;
avisado[playerid]=-1;
DisablePlayerRaceCheckpoint(playerid);
contador[playerid]=0;
return 1;
}
//------------------------------------------------------------------------------------------------------
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate==PLAYER_STATE_DRIVER)
{
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
{
if (avisado[playerid]==-1)
{
GameTextForPlayer(playerid,"~w~Press ~b~Buttom 2~n~~w~to start ~r~PizzaBoy~n~~w~Sidejob",3000,5);//SetTimerEx("MandarMensaje",5500,0,"%d",playerid);
}
else
{
KillTimer(avisado[playerid]);
avisado[playerid]=-1;
}
}
}
if (newstate==PLAYER_STATE_ONFOOT)
{
if ((playerInMiniMission[playerid]>0)&&(avisado[playerid]==-1))
{
GameTextForPlayer(playerid,"~w~You have ~r~10 sec ~n~~w~ to get a pizza bike",3000,4);
avisado[playerid]=SetTimerEx("terminarMission",10000,0,"%d",playerid);
}
}
return 1;
}
//------------------------------------------------------------------------------------------------------
getNearestPizzeria(Float:X1,Float:Y1,Float:Z1)
{
new index;
new Float:distOld=9999.0;
new Float:distNew=0.0;
for (new i=0;i<cantidadPizzerias;i++)
{
distNew=floatsqroot(floatpower(floatabs(floatsub(Pizzerias[i][X],X1)),2)+floatpower(floatabs(floatsub(Pizzerias[i][Y],Y1)),2)+floatpower(floatabs(floatsub(Pizzerias[i][Z],Z1)),2));
if (distNew<distOld)
{
distOld=distNew;
index=i;
}
}
return index;
}
//------------------------------------------------------------------------------------------------------
pizzeriaAcasa(playerid)
{
new Float:X1,Float:Y1,Float:Z1;
GetPlayerPos(playerid,X1,Y1,Z1);
new index = getNearestPizzeria(X1,Y1,Z1);
new index2 = random(cantidadDestinos);
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid,0,Pizzerias[index][X],Pizzerias[index][Y],Pizzerias[index][Z],Destinos[index2][X],Destinos[index2][Y],Destinos[index2][Z],3.0);
playerInMiniMission[playerid]=index2;
return 1;
}
//------------------------------------------------------------------------------------------------------
casaApizzeria(playerid)
{
new index2 = playerInMiniMission[playerid];
new index = getNearestPizzeria(Destinos[index2][X],Destinos[index2][Y],Destinos[index2][Z]);
DisablePlayerRaceCheckpoint(playerid);
SetPlayerRaceCheckpoint(playerid,0,Destinos[index2][X],Destinos[index2][Y],Destinos[index2][Z],Pizzerias[index][X],Pizzerias[index][Y],Pizzerias[index][Z],3.0);
playerInMiniMission[playerid]=0;
return 1;
}
//------------------------------------------------------------------------------------------------------
MissionIni(playerid)
{
GameTextForPlayer(playerid,"~r~PizzaBoy ~w~MiniMision ~w~Starts!~n~ Quick! go to nearest ~r~ pizzeria~w~!",3000,4);
pizzeriaAcasa(playerid);
return 1;
}
//------------------------------------------------------------------------------------------------------
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if ((newkeys==KEY_SUBMISSION)&&(IsPlayerInAnyVehicle(playerid))&&(GetPlayerState(playerid)==PLAYER_STATE_DRIVER))
{
if (GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
{
if (playerInMiniMission[playerid]<0)
{
MissionIni(playerid);
}
else
{
terminarMission(playerid);
}
}
}
}
//------------------------------------------------------------------------------------------------------
public OnPlayerEnterRaceCheckpoint(playerid)
{
if (playerInMiniMission[playerid]!=-1)
{
if (playerInMiniMission[playerid]==0)
{
GameTextForPlayer(playerid,"~r~Pizza ~w~delivered!~n~ Quick! go to nearest ~r~ pizzeria~w~~n~ more work to do!",3000,3);
new cash=(random(MAX_CASH-MIN_CASH)+MIN_CASH);
GivePlayerMoney(playerid,cash);
pizzeriaAcasa(playerid);
contador[playerid]++;
}
else
{
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 pizzas!.~n~You delivered %d pizzas your bonus is ~n~~b~$%d",contador[playerid],contador[playerid]*BONUS);
GameTextForPlayer(playerid,string,3000,3);
}
else
{
GameTextForPlayer(playerid,"~w~Quick deliver this~n~~r~pizza",3000,3);
}
casaApizzeria(playerid);
}
}
return 1;
}
//------------------------------------------------------------------------------------------------------
public OnPlayerDisconnect(playerid)
{
terminarMission(playerid);
return 1;
}
So is there anything i can do so that the money earned is actually added to the player?
Serverside money is on the gamemode. Thanks
- EDIT: So I need to add a callback to make it work with the serverside money anti cheat that is in the game mode.
This is how a player gets money in the game mode (dropping off a car at a checkpoint in the GM)
pawn Code:
SendClientMessage(playerid, COLOR_LIGHTBLUE, "* You sold a car for $2000, your reload time is 10 minutes.");
PlayerInfo[playerid][pCash] = PlayerInfo[playerid][pCash]+2000;
GivePlayerMoney(playerid, 2000);
pawn Code:
public OnPlayerEnterRaceCheckpoint(playerid)
{
if (playerInMiniMission[playerid]!=-1)
{
if (playerInMiniMission[playerid]==0)
{
GameTextForPlayer(playerid,"~r~Pizza ~w~delivered!~n~ Quick! go to nearest ~r~ pizzeria~w~~n~ more work to do!",3000,3);
new cash=(random(MAX_CASH-MIN_CASH)+MIN_CASH);
CallRemoteFunction("GivePlayerMoney","i",playerid,cash); //Payout - NOT WORKING
pizzeriaAcasa(playerid);
contador[playerid]++;
}
else
{
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 pizzas!.~n~You delivered %d pizzas your bonus is ~n~~b~$%d",contador[playerid],contador[playerid]*BONUS);
GameTextForPlayer(playerid,string,3000,3);
}
else
{
GameTextForPlayer(playerid,"~w~Quick deliver this~n~~r~pizza",3000,3);
}
casaApizzeria(playerid);
}
}
return 1;
}