rendered paste body#include <a_samp>//=====COLORS===============================#define COLOR_ORANGE 0xFF6600AA#define COLOR_RED 0xFF0000AA#define COLOR_BLUE 0x0080FFAA#define COLOR_GREEN 0x33FF33AA#define COLOR_YELLOW 0xE6E600AA#define COLOR_ORANGE 0xFF6600AA//=====GLOBALS==============================new gTaxiDriver[MAX_PLAYERS];new gTaxiDriverSkill[MAX_PLAYERS];//=====TIMERS===============================//new is_driver_in_taxi;//new is_driver_outta_taxi;//=====ARRAYS===============================new Payment[5] = {1000, // 05000, // 110000,// 215000,// 320000 // 4};//=====MISC=================================new every_5;main(){ print("\n----------------------------------"); print(" Test: Taxi Driver"); print("----------------------------------\n");}//------------------------------------------------------------------------------public OnGameModeInit(){ SetGameModeText("(work in progress)"); SetTimer("TaxiPayment", 10000, true); SetTimer("OuttaTaxi", 20000, true); AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0); AddStaticVehicle(420, 2022.1577, 1340.6592, 10.6805, 305.6671, 6, 6); // Taxi return 1;}//------------------------------------------------------------------------------public OnPlayerRequestClass(playerid, classid){ SetPlayerInterior(playerid,0); SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); SetPlayerCameraPos(playerid, 1964.3783, 1343.1572, 16.3746); SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); return 1;}//------------------------------------------------------------------------------public OnPlayerSpawn(playerid){ SendClientMessage(playerid, COLOR_BLUE, "Commands:"); SendClientMessage(playerid, COLOR_GREEN, "/taxidriver"); SendClientMessage(playerid, COLOR_GREEN, "/myskill"); return 1;}//------------------------------------------------------------------------------public OnPlayerDisconnect(playerid){ gTaxiDriver[playerid]=0; gTaxiDriverSkill[playerid]=0; return 1;}//------------------------------------------------------------------------------public OnPlayerDeath(playerid, killerid, reason){ new tmp[128]; new drivername[MAX_PLAYER_NAME]; if (gTaxiDriver[playerid] >0){ gTaxiDriver[playerid]=0; gTaxiDriverSkill[playerid]=0; GetPlayerName(playerid, drivername, sizeof(drivername)); format (tmp, sizeof(tmp), "*** %s is no longer taxi driver.", drivername); SendClientMessageToAll (COLOR_ORANGE, tmp); SendClientMessage(playerid, COLOR_RED, "*** You lost your taxi driver job."); } return 1;}//------------------------------------------------------------------------------public OnPlayerCommandText(playerid, cmdtext[]){ new tmp[128]; new string[128]; new pName[MAX_PLAYER_NAME]; if (strcmp(cmdtext, "/taxidriver", true)==0){ if (gTaxiDriver[playerid] == 0){ //is_driver_in_taxi = SetTimer("TaxiPayment",15000,true); GetPlayerName(playerid, pName, sizeof(pName)); format(tmp, sizeof(tmp), "*** %s's just started working as a Taxi Driver.",pName); if(IsPlayerInVehicle(playerid,1) && GetPlayerState(playerid) == 2){ SendClientMessage(playerid, COLOR_YELLOW, tmp); SendClientMessage(playerid, COLOR_YELLOW, "*** Type /help-taxi to get started."); gTaxiDriver[playerid]++; gTaxiDriverSkill[playerid]=0; format (string, sizeof(string), "*** Your current skill is: %d.",GetDriverSkill(playerid)); SendClientMessage(playerid, COLOR_ORANGE, string); } else{ SendWarningMessage(playerid); } } else{ SendClientMessage(playerid, COLOR_RED, "*** You're already the taxi driver."); } return 1; } if (strcmp(cmdtext, "/help-taxi", true)==0){ /* some help information */ return 1; } if (strcmp(cmdtext, "/myskill", true)==0){ if (gTaxiDriver[playerid] >1){ format(tmp,sizeof(tmp),"*** Your current skill is: %d.",GetDriverSkill(playerid)); SendClientMessage(playerid, COLOR_ORANGE, tmp); } else{ SendWarningMessage(playerid); } return 1; } return 0;}//------------------------------------------------------------------------------public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger){ printf("OnPlayerEnterVehicle(%d, %d, %d)", playerid, vehicleid, ispassenger); /* if (vehicleid==1 && gTaxiDriver[playerid] >0){ is_driver_in_taxi = SetTimer("TaxiPayment",15000,true); } */ return 1;}//------------------------------------------------------------------------------public OnPlayerExitVehicle(playerid, vehicleid){ printf("OnPlayerExitVehicle(%d, %d)", playerid, vehicleid); /* if (vehicleid==1 && gTaxiDriver[playerid] >0){ is_driver_outta_taxi = SetTimer("OuttaTaxi", 10000, true); KillTimer(is_driver_in_taxi); } */ return 1;}//------------------------------------------------------------------------------//==============================================================================//------------------------------------------------------------------------------public TaxiPayment(playerid){ new i,j; new tmp[128]; new string[128]; for (i=0; i<MAX_PLAYERS; i++){ if (IsPlayerConnected(i)){ for (j=0; j<MAX_PLAYERS; j++){ if (gTaxiDriver[j] ==1){ if (IsPlayerInVehicle(j,1) && GetPlayerState(j)==2){ gTaxiDriverSkill[j]++; format (tmp, sizeof(tmp), "*** Your current skill is: %d.",GetDriverSkill(j)); if (gTaxiDriverSkill[j] >0 && gTaxiDriverSkill[j] <5 && GetPlayerState(j)==2){ format (string, sizeof(string), "*** You recived $%d as taxi driver.",Payment[0]); SendClientMessage(j, COLOR_YELLOW, string); SendClientMessage(j, COLOR_ORANGE, tmp); GivePlayerMoney(j,Payment[0]); } else if (gTaxiDriverSkill[j] >5 && gTaxiDriverSkill[j] <10 && GetPlayerState(j)==2){ format (string, sizeof(string), "*** You recived $%d as taxi driver.",Payment[1]); SendClientMessage(j, COLOR_YELLOW, string); SendClientMessage(j, COLOR_ORANGE, tmp); GivePlayerMoney(j, Payment[1]); } else if (gTaxiDriverSkill[j] >10 && gTaxiDriverSkill[j] <15 && GetPlayerState(j)==2){ format (string, sizeof(string), "*** You recived $%d as taxi driver.",Payment[2]); SendClientMessage(j, COLOR_YELLOW, string); SendClientMessage(j, COLOR_ORANGE, tmp); GivePlayerMoney(j, Payment[2]); } else if (gTaxiDriverSkill[j] >15 && gTaxiDriverSkill[j] <20 && GetPlayerState(j)==2){ format (string, sizeof(string), "*** You recived $%d as taxi driver.",Payment[3]); SendClientMessage(j, COLOR_YELLOW, string); SendClientMessage(j, COLOR_ORANGE, tmp); GivePlayerMoney(j, Payment[3]); } every_5 = gTaxiDriverSkill[j]; switch (every_5) { case 5: { format (string, sizeof(string), "*** You recived $%d as taxi driver.",Payment[1]); SendClientMessage(j, COLOR_YELLOW, string); SendClientMessage(j, COLOR_ORANGE, tmp); GivePlayerMoney(j, Payment[3]); } case 10: { format (string, sizeof(string), "*** You recived $%d as taxi driver.",Payment[2]); SendClientMessage(j, COLOR_YELLOW, string); SendClientMessage(j, COLOR_ORANGE, tmp); GivePlayerMoney(j, Payment[3]); } case 15: { format (string, sizeof(string), "*** You recived $%d as taxi driver.",Payment[3]); SendClientMessage(j, COLOR_YELLOW, string); SendClientMessage(j, COLOR_ORANGE, tmp); GivePlayerMoney(j, Payment[3]); } case 20: { format (string, sizeof(string), "*** You recived $%d as taxi driver.",Payment[4]); SendClientMessage(j, COLOR_YELLOW, string); SendClientMessage(j, COLOR_ORANGE, tmp); GivePlayerMoney(j, Payment[4]); gTaxiDriver[j]++; } } } } } } }}//------------------------------------------------------------------------------public OuttaTaxi (playerid){ new i,j; new tmp[128]; new drivername[MAX_PLAYER_NAME]; for(i=0; i<MAX_PLAYERS; i++){ if (IsPlayerConnected(i)){ for (j=0; j<MAX_PLAYERS; j++){ if (gTaxiDriver[j] >0){ if (GetPlayerState (j) !=2 && IsPlayerInVehicle (j, !1)){ gTaxiDriver[j]=0; gTaxiDriverSkill[j]=0; GetPlayerName(j,drivername,sizeof(drivername)); format (tmp, sizeof(tmp), "*** %s is no longer taxi driver.", drivername); SendClientMessageToAll(COLOR_ORANGE, tmp); SendClientMessage(j, COLOR_RED, "*** You lost your taxi driver job!"); } } } } }}//------------------------------------------------------------------------------public GetDriverSkill(playerid){ return gTaxiDriverSkill[playerid];}//------------------------------------------------------------------------------public SendWarningMessage(playerid){ SendClientMessage(playerid, COLOR_RED, "Read /help-taxi and then try again!");}//------------------------------------------------------------------------------