car export - problem - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: car export - problem (
/showthread.php?tid=74671)
car export - problem -
Mike-Chip - 25.04.2009
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!
Re: car export - problem -
Nubotron - 25.04.2009
http://forum.sa-mp.com/index.php?topic=95452 and there is some scripting errors in your code
Re: car export - problem -
Mike-Chip - 25.04.2009
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
Re: car export - problem -
Joe Staff - 25.04.2009
You need to turn the Float value 'vHealth' into an integer I think round(Float:float) does that not sure.
Re: car export - problem -
Mike-Chip - 25.04.2009
but how I do that ?
Re: car export - problem -
Nubotron - 25.04.2009
new FinalValue = floatround( ExportPayment * ( VHealth / 1000 ) );
Re: car export - problem -
Mike-Chip - 25.04.2009
Thanks man, worked like a charm :P