Taxi Payment Script -
SkyWinder - 24.07.2012
Hello,
I was wondering whats the issue in this code.
Код:
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 538)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
new pveh = GetPlayerVehicleID(playerid);
new PName[24];
GetPlayerName(i, PName, 24);
if(AccountGetInt(PName[i], "Job") == 2)
{
if(GetPlayerVehicleID(i) == pveh)
{
if(i == PLAYER_STATE_DRIVER)
{
GiveMoney(playerid, -AccountGetInt(PName[i], "DriverFee"));
GiveMoney(i, AccountGetInt(PName[i], "DriverFee"));
new string[60];
format(string, sizeof(string), "You have paid Taxi Driver %s $%d", PName[i], AccountGetInt(PName[i], "DriverFee"));
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "You were paid $%d by your passenger.", AccountGetInt(PName[i], "DriverFee"));
SendClientMessage(playerid, COLOR_YELLOW, string);
}
}
}
}
}
Re: Taxi Payment Script -
doreto - 24.07.2012
What is the problem in this code ? error ? no working ?
Re: Taxi Payment Script -
SkyWinder - 24.07.2012
Not working.
Re: Taxi Payment Script -
Akira297 - 24.07.2012
Do you have.
DriverFee defined?
Re: Taxi Payment Script -
SkyWinder - 24.07.2012
Yes, Its defined.
Re: Taxi Payment Script -
Cjgogo - 24.07.2012
Removed![Not a porper answer]!Please tell me how the system should work?
Re: Taxi Payment Script -
SkyWinder - 24.07.2012
When the player enters the Taxi, he should pay the driver the fee when he exits.
Re: Taxi Payment Script -
Cjgogo - 24.07.2012
This might work,but I am not sure:
pawn Код:
new TaxiPassenger[MAX_PLAYERS];//at the top of your gamemode
new TaxiDriver;//we will use this variable to store the taxi driver's ID
//Good,we will use that variable to confirm the player was passenger in a taxi,so when he connects,set the variable to 0 :P.Good now the actual code:
public OnPlayerStateChange(playerid,newstate,oldstate)
{
if(newstate==PLAYER_STATE_PASSENGER)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid))==538)
{
vehicleid=GetPlayerVehicleID(playerid);//we also need the vehicleid,beside the model,you'll see why
for(new i=0;i<MAX_PLAYERS;i++)
{
if(GetPlayerVehicleID(i)==vehicleid)//we check if any of the players is in the same vehicle as you
{
if(GetPlayerState(i)==PLAYER_STATE_DRIVER))//then we check if he's a driving the car :P
{
TaxiPassenger[playerid]=1;//you are passenger in a taxi
TaxiDriver=i;//we stored the driver's ID
break;//we exited the loop,as every condition matches
}
}
}
}
}
//GOOD,now,when you exit the car,if your variable TaxiPassenger equals 1,it means you were passenger in a taxi
if(newstate==PLAYER_STATE_ONFOOT&&oldstate==PLAYER_STATE_PASSENGER&&TaxiPassenger[playerid]==1)
{
//changed i to TaxiDriver,but the money system code is the same
GiveMoney(playerid, -AccountGetInt(PName[TaxiDriver], "DriverFee"));
GiveMoney(TaxiDriver, AccountGetInt(PName[TaxiDriver], "DriverFee"));
new string[60];
format(string, sizeof(string), "You have paid Taxi Driver %s $%d", PName[TaxiDriver], AccountGetInt(PName[TaxiDriver], "DriverFee"));
SendClientMessage(playerid, COLOR_YELLOW, string);
format(string, sizeof(string), "You were paid $%d by your passenger.", AccountGetInt(PName[TaxiDriver], "DriverFee"));
SendClientMessage(playerid, COLOR_YELLOW, string);
TaxiDriver[playerid]=0;//he is not anymore passenger in a taxi
}
return 1;
}
I scripted it in a rush,so backup YOUR CODE,and then test mine
Re: Taxi Payment Script -
SkyWinder - 24.07.2012
The Code works fine now just that the TaxiDriver's ID is messed up. i dont think the TaxiDriver[playerid] works
Re: Taxi Payment Script -
Cjgogo - 24.07.2012
Well,then sorry,try get someone else's help and find a way around with my code,I am glad I could help but i g2g
leave me a message on profile if you get it to work bye