25.04.2009, 02:16
Hi all,
i'm trying to make a function that when a player export a vehicle and the vehicle is damaged the money will be decreased according to the damage. But the following code doesn't work properly... dunno why, seems fine...
Thanks in Advance!
i'm trying to make a function that when a player export a vehicle and the vehicle is damaged the money will be decreased according to the damage. But the following code doesn't work properly... dunno why, seems fine...
Код:
public SellExportVehicle(playerid)
{
new string[256], i;
new Float:vhealth;
new GetVHealth = GetVehicleHealth(GetPlayerVehicleID(playerid), vhealth);
new VHealthLost = (GetVHealth - 1000);
new FirstValue = (ExportPayment / 1000);
new SecondValue = (FirstValue * VHealthLost);
new EndValue = (ExportPayment - SecondValue);
for(i=0; i<MAX_EXPORTVEHICLES; i++) {
if(ExportVehicles[i]==ExportVehicle) {
wantedVehicle = i;
break;
}
}
if(wantedVehicle>=0)
{
if(IsPlayerInAnyVehicle(playerid))
{
if( GetVehicleModel( GetPlayerVehicleID(playerid) ) == ExportVehicle )
{
if(GetPlayerState(playerid) == PLAYER_STATE_DRIVER)
{
format(string, sizeof(string), "Excellent, we will export your %s at once! Here is $%d for your services.", ExportVehicleNames[i], EndValue);
SendClientMessage(playerid, COLOR_GREEN, string);
format(string, sizeof(string), "%s has exported a %s, and earned $%d! ", pName(playerid), ExportVehicleNames[i], EndValue);
SendClientMessageToAll(COLOR_GREEN, string);
format(string, sizeof(string), "$%d", EndValue);
GameTextForPlayer(playerid, string, 4000,3);
GivePlayerPCash(playerid, EndValue);
PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
EndExports();
return SetVehicleToRespawn(GetPlayerVehicleID(playerid));
}
} else return SendClientMessage(playerid, COLOR_YELLOW, "We aren't buying this vehicle at the time!");
}
else format(string, sizeof(string), "We are currently buying %s's for export.", ExportVehicleNames[i]);
return SendClientMessage(playerid, COLOR_ORANGE, string);
} else return SendClientMessage(playerid, COLOR_YELLOW, "We aren't buying any vehicle at the time!");
}

