Cash Cab

Newbie Spellweaver
Joined
Sep 3, 2009
Messages
86
Reaction score
8
Code:
new CashCabPayout[MAX_PLAYERS];
new InCashCab[MAX_PLAYERS];
new CashCabFare;

Code:
public IsACashCabDriver(playerid) {
	if(IsPlayerConnected(playerid)) {
	    new leader = PlayerInfo[playerid][pLeader];
	    new member = PlayerInfo[playerid][pMember];
	    if(member == 13 || leader == 13) {
	        return 1;
		}
		return 0;
	}
}
public IsACashCab(carid) {
	if(carid == 545 || carid == 549 || carid == 541 || carid == 547 || carid == 504) {
	    return 1;
	}
	return 0;
}

Code:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
	if(PlayerInfo[playerid][pJailed] == 2)
	{
	    new string[256];
	    SendClientMessage(playerid, COLOR_LIGHTRED, "~ Do not bug abuse or get banned! ~");
	    new Float:cx, Float:cy, Float:cz;
		GetPlayerPos(playerid, cx, cy, cz);
		SetPlayerPos(playerid, cx,  cy, cz);
		new giveplayer[MAX_PLAYER_NAME];
		GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
		format(string, sizeof(string), "[SERVER]: %s has been trying to prisonbreak from admin jail!", giveplayer);
		ABroadCast(COLOR_YELLOW,string,1);
	}
    if (dying[playerid] == 1)
	{
		SendClientMessage(playerid, COLOR_GRAD2, "~ You can`t drive when you are dying! ~");
		TogglePlayerControllable(playerid, 0);
		ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);
	}
	if(gTeam[playerid] >= 1||gTeam[playerid] >= 3||gTeam[playerid] >= 4)
	{
		if (IsACopCar(vehicleid) && !ispassenger)
		{
			if(IsACop(playerid) || IsASheriff(playerid)) {}
		    else {
				//WantedPoints[playerid]+=2;
				//SetPlayerCriminal(playerid,255, "Stealing A Police Vehicle");
				new Float:cx, Float:cy, Float:cz;
				GetPlayerPos(playerid, cx, cy, cz);
				SetPlayerPos(playerid, cx,  cy, cz);
			}
		}
		if(!ispassenger) {
		    for(new i=0; i<MAX_PLAYERS; i++) {
		        if(GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER) {
		            new Float:cx, Float:cy, Float:cz;
		            new Float:ccx, Float:ccy, Float:ccz;
					if(IsACop(playerid)) {
					    GetPlayerPos(playerid, ccx, ccy, ccz);
					    GetPlayerPos(i, cx, cy, cz);
					    SetPlayerPos(i, ccx - 5, ccy, ccz);
					    PlayerCuffed[i] = 1;
					    PlayerCuffedTime[i] = 9999;
					}
					return 1;
				 }
			  }
			  return 1;

		}
		if(IsACashCab(vehicleid) && ispassenger) {
			SendClientMessage(playerid, COLOR_GREEN, "Congratulations! You have just entered the cash cab!");
			SendClientMessage(playerid, COLOR_GREEN, "You will be asked questions on your way to your destination and will win money for answering them correctly");
			InCashCab[playerid] = 1;
			GiveCash(playerid, -CashCabFare);
		}
		if(IsAGarageCar(vehicleid) && !ispassenger)
		{
		    if(IsAGarageMan(playerid)) {}
		    else {
		        new Float:cx, Float:cy, Float:cz;
				GetPlayerPos(playerid, cx, cy, cz);
				SetPlayerPos(playerid, cx,  cy, cz);
      		}
		}
		/*if (IsASheriffCar(vehicleid) && !ispassenger)
		{
			if(IsASheriff(playerid) || IsACop(playerid)) {}
		    else {
				SendClientMessage(playerid,COLOR_GRAD2,"A warrant has been added for your arrest:Reason:Driving a cop car");
                if(WantedPoints[playerid] == 0) { WantedPoints[playerid] = 3; }
							else { WantedPoints[playerid]+= 2; }
							SetPlayerCriminalEx(playerid,playerid, result);}
			}
		}
  		if(!ispassenger)
    	{
        for(new i=0; i<MAX_PLAYERS; i++)
        {
            if(GetPlayerVehicleID(i) == vehicleid && GetPlayerState(i) == PLAYER_STATE_DRIVER)
            {
                SendClientMessage(playerid,COLOR_GRAD2,"A warrant has been added for your arrest:Reason:Stealing a car");
                if(WantedPoints[playerid] == 0) { WantedPoints[playerid] = 3; }
							else { WantedPoints[playerid]+= 2; }
							SetPlayerCriminalEx(playerid,playerid, result);}
            }
        }
    }*/
		if (IsAnAmbulance(vehicleid) && !ispassenger)
		{
		    if(PlayerInfo[playerid][pMember]==4||PlayerInfo[playerid][pLeader]==4) { }
		    else
			{
				new Float:cx, Float:cy, Float:cz;
				GetPlayerPos(playerid, cx, cy, cz);
				SetPlayerPos(playerid, cx,  cy, cz);
			}
		}
	}
	return 1;
}
public OnPlayerExitVehicle(playerid, vehicleid)
{
	if (GetPlayerState(playerid) == 1)
	{
		return 1;
	}
	if(dying[playerid] == 1){TogglePlayerControllable(playerid, 0); ApplyAnimation(playerid,"PED","KO_skid_front",4.1,0,1,1,1,0);}
	AffectVehicleDamageToPlayer(playerid,vehicleid,0);
	if(IsAHarvest(vehicleid))
	{
	    if(FarmerVar[playerid] == 1)
	    {
			SetTimer("FarmerExit", 7000, 0);
			GameTextForPlayer(playerid, "~n~~w~You have ~r~7~w~ seconds~n~to get back on a harvest", 5000, 3);
	    }
	}
	if(IsADrugHarvest(vehicleid))
	{
	    if(DrugFarmerVar[playerid] == 1)
	    {
			SetTimer("DrugFarmerExit", 7000, 0);
			GameTextForPlayer(playerid, "~n~~w~You have ~b~7~w~ seconds~n~to get back on a harvest", 5000, 3);
	    }
	}
	if(IsADmv(vehicleid))
	{
	}
	if(IsASmuggleCar(vehicleid))
	{
	    if(SmugglerWork[playerid] == 1)
	    {
	        SetTimer("SmugglerExit", 7000, 0);
	        GameTextForPlayer(playerid, "~n~~w~You have ~r~7~w~ seconds~n~to get back in car", 5000, 3);
		}
	}
	if(gGas[playerid] == 1)
	{
	    GameTextForPlayer(playerid, "~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~~n~Left car", 500, 3);
	}
	if (BusrouteEast[playerid][0] != 0 || BusrouteWest[playerid][0] != 0)
	{
		BusrouteEnd(playerid, vehicleid);
	}
	if(IsACashCab(vehicleid)) {
	    for(new i=0; i<=PLAYERS; i++) {
	        if(IsPlayerConnected(i)) {
	            if(CashCabPayout[i] > 0) {
					SendClientMessage(i, COLOR_GREEN, "You have won some money in the cash cab!");
	                GiveCash(i, CashCabPayout[i]);
	                CashCabPayout[i] = 0;
	                InCashCab[i] = 0;
				} else {
					SendClientMessage(i, COLOR_LIGHTRED, "Sorry but you have not won anything in the cash cab");
				}
			  }
		   }
	}
	if (IsABus(vehicleid))
	{
		for (new i=0; i<=PLAYERS; i++)
		{
			if (IsPlayerConnected(i))
			{
				if (BusrouteEast[i][0] != 0 && BusrouteEast[i][1] == vehicleid)
				{
					GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~g~Passenger Left The Bus", 5000, 3);
				}
				else if (BusrouteWest[i][0] != 0 && BusrouteWest[i][1] == vehicleid)
				{
					GameTextForPlayer(i, "~n~~n~~n~~n~~n~~n~~g~Passenger Left The Bus", 5000, 3);
				}
			}
		}
	}
	if(SeatBelt[playerid]==true)
    {
        new string[256];
    	SeatBelt[playerid]=false;
    	format(string, sizeof(string), "* %s unbuckles his/her seat belt", GetPlayerNameEx(playerid));
		ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
	}
	return 1;
}

Code:
if(strcmp(cmd, "/ccfare", true) == 0) {
	    if(IsPlayerConnected(playerid)) {
	        if(IsACashCabDriver(playerid)) {
	            new moneys;
				tmp = strtok(cmdtext, idx);
				if(!strlen(tmp)) {
				    SendClientMessage(playerid, COLOR_WHITE, "USAGE: /ccfare [price]");
				    return 1;
			    }
			    moneys = strval(tmp);
			    if(moneys > 0 && moneys < 7501) {
			        CashCabFare = moneys;
			        format(string, sizeof(string), "Cash Cab Driver %s is on duty with a entry fee of %d", sendername, CashCabFare);
			        OOCNews(TEAM_GROVE_COLOR, string);
				} else {
				    SendClientMessage(playerid, COLOR_GREY, "Fare cannot be higher than 7500");
				}
		     } else {
		        SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command");
			 }
		  }
		return 1;
	}
if(strcmp(cmd, "/payout", true) == 0) {
	    if(IsPlayerConnected(playerid)) {
	        tmp = strtok(cmdtext, idx);
	        if(!strlen(tmp)) {
	            SendClientMessage(playerid, COLOR_GREY, "USAGE: /payout [playerid/PartOfName] [amount]");
				return 1;
			}
			new playa;
			new money;
			new tmpcar = GetPlayerVehicleID(playerid);
			playa = ReturnUser(tmp);
			tmp = strtok(cmdtext, idx);
			money = strval(tmp);
			if(IsACashCabDriver(playerid)) {
			    if(IsPlayerConnected(playa)) {
			        if(playa != INVALID_PLAYER_ID) {
			            if(GetDistanceBetweenPlayers(playerid, playa) < 16) {
			                if(InCashCab[playa] == 1) {
			                    if(IsACashCab(tmpcar)) {
			                        CashCabPayout[playa] = CashCabPayout[playa] + money;
									format(string, sizeof(string), "You have earned $%d more in the cash cab!", money);
		                        	SendClientMessage(playa, COLOR_GREEN, string);
								} else {
								    SendClientMessage(playerid, COLOR_GREY, "You are not in a cash cab");
								}
							 } else {
							    SendClientMessage(playerid, COLOR_GREY, "That person is not in a cab");
							 }
						 } else {
						    SendClientMessage(playerid, COLOR_GREY, "That player is not in your cash cab");
						 }
					  }
				   } else {
					  SendClientMessage(playerid, COLOR_GREY, "Player is unexistant");
				   }
			 } else {
			    SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use this command");
			 }
		}
		return 1;
	}
	if(strcmp(cmd, "/question", true) == 0) {
	    new tmpcar = GetPlayerVehicleID(playerid);
        new x_nr[256];
        x_nr = strtok(cmdtext, idx);
        if(!strlen(x_nr)) {
            SendClientMessage(playerid, COLOR_GREY, "USAGE: /question [1-15]");
            return 1;
		}
        if(IsACashCab(tmpcar)) {
            if(strcmp(x_nr, "1", true) == 0) {
                format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current president of the united states?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Barack (Obama)");
	 		} else if(strcmp(x_nr, "2", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current dictator of North Korea?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Kim Jon Il");
			} else if(strcmp(x_nr, "3", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: What is 2 + 2 x 2?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "6");
			} else if(strcmp(x_nr, "4", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who was the singer who created the song nicknamed (The Rick Roll)?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Rick Astley");
			} else if(strcmp(x_nr, "5", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: What is the name of 1 of the 6 gangs fighting the Grove Street Famliies?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Da Nang Boys/Triads/San Fierro (Rifa)/Los Santos (Vagos)/Varios Los (Aztecas)/The (Ballas)");
			} else if(strcmp(x_nr, "6", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: What is Zero's RC Shop?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "A (comic shop)");
			} else if(strcmp(x_nr, "7", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: What is the last area you go to in Grand Theft Auto San Andreas?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Los Santos");
			} else if(strcmp(x_nr, "8", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who was on CJ's side at the end of the game Grand Theft Auto San ANdreas?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Sweet");
			} else if(strcmp(x_nr, "9", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current president of the united states?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Barack Obama");
			} else if(strcmp(x_nr, "10", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current president of the united states?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Barack Obama");
			} else if(strcmp(x_nr, "11", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current president of the united states?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Barack Obama");
			} else if(strcmp(x_nr, "12", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current president of the united states?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Barack Obama");
			} else if(strcmp(x_nr, "13", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current president of the united states?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Barack Obama");
			} else if(strcmp(x_nr, "14", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current president of the united states?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Barack Obama");
			} else if(strcmp(x_nr, "15", true) == 0) {
	 		    format(string, sizeof(string), "Cash Cab Driver %s asks: Who is the current president of the united states?", sendername);
                ProxDetector(15.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
				SendClientMessage(playerid, COLOR_WHITE, "Barack Obama");
			}
		} else {
		    SendClientMessage(playerid, COLOR_GREY, "You are not in a cash cab");
		}
		return 1;
	}

I need help fixing this up. When I go as a driver and the person is in my car in one of the vehicles I put in IsACashCab, it sais I'm not in a cash cab.
 
The vehicle IDs are correct.

The script is supposed to have the player enter a cash cab drivers car and then they get sent a message saying you entered and then the driver asks /questions [1-15] the whole way there but it only works in a cash cab and for every question correct the driver /payout [playerid] [amount] the player and when the player gets out they get all the money they earned.
 
Last edited:
so do you get these messages when you enter the cab?

SendClientMessage(playerid, COLOR_GREEN, "Congratulations! You have just entered the cash cab!");
SendClientMessage(playerid, COLOR_GREEN, "You will be asked questions on your way to your destination and will win money for answering them correctly");
 
Code:
if(gTeam[playerid] >= 1||gTeam[playerid] >= 3||gTeam[playerid] >= 4)
	{
maybe you are not in one of these teams?

as far as i can see ( i might be overlooking something tho ) it's either that or this function:

Code:
IsACashCab(vehicleid)
that causes the problem..
 
Back