car export - problem
#1

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...
Код:
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!");
}
Thanks in Advance!
Reply
#2

http://forum.sa-mp.com/index.php?topic=95452 and there is some scripting errors in your code
Reply
#3

Thanks man, but it gets a warning message:
ah... ExportPayment = (random(10)+10)*1000;

Код:
Line 3220: new Float:VHealth;
Line 3221: GetVehicleHealth(GetPlayerVehicleID(playerid),VHealth);
Line 3222: new FinalValue = ( ExportPayment * ( VHealth / 1000 ) );
Код:
D:/GTASAN~1/GTASAM~1/GAMEMO~1/lswars.pwn(3222) : warning 213: tag mismatch
Reply
#4

You need to turn the Float value 'vHealth' into an integer I think round(Float:float) does that not sure.
Reply
#5

but how I do that ?
Reply
#6

new FinalValue = floatround( ExportPayment * ( VHealth / 1000 ) );
Reply
#7

Thanks man, worked like a charm :P
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)