repair vehicle question! :D -
WillyP - 03.09.2010
so.... your vehicle is damaged, say 234/1000 hp and you type /repair
but the thing is, the more damage, the more the repair will cost!
idk how to to the variable bit but im sure someone will start me off
Re: repair vehicle question! :D -
CyNiC - 03.09.2010
Post the funtion what show the ammount of damage.
Re: repair vehicle question! :D -
Mauzen - 03.09.2010
You can do this:
cost = (1000 - vehiclehealth) * PRICE_PER_DAMAGE_POINT
Re: repair vehicle question! :D -
gamer931215 - 03.09.2010
try this (didnt test it)
pawn Код:
dcmd_fix(playerid,params[]){
#pragma unused params
if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not in an vehicle!");
if (GetVehicleDamage(GetPlayerVehicleID(playerid)) > GetPlayerMoney(playerid)) return SendClientMessage(playerid,COLOR_RED,"You dont have enough money!");
RepairVehicle(GetPlayerVehicleID(playerid));
SendClientMessage(playerid,COLOR_GREEN,"Your vehicle has been repaired!");
}
stock GetVehicleDamage(vehicleid)
{
new Float:vhealth;
GetVehicleHealth(GetPlayerVehicleID(playerid),vhealth);
return (1000 - vhealth);
}
Hope it works , did only test it for warnings/errors.
Didnt test it, so hope it works
Edit others were faster as me, anyways i guess this function works then because that other guy says the same.
Re: repair vehicle question! :D -
Voldemort - 03.09.2010
You need to decide will you use float(Money); or floatround(VehicleHealth);
than we can talk about cmds, but Suggest to float(Money);
Re: repair vehicle question! :D -
WillyP - 03.09.2010
Quote:
Originally Posted by gamer931215
try this (didnt test it)
pawn Код:
dcmd_fix(playerid,params[]){ #pragma unused params if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,COLOR_RED,"You are not in an vehicle!"); if (GetVehicleDamage(GetPlayerVehicleID(playerid)) > GetPlayerMoney(playerid)) return SendClientMessage(playerid,COLOR_RED,"You dont have enough money!"); RepairVehicle(GetPlayerVehicleID(playerid)); SendClientMessage(playerid,COLOR_GREEN,"Your vehicle has been repaired!"); } stock GetVehicleDamage(vehicleid) { new Float:vhealth; GetVehicleHealth(GetPlayerVehicleID(playerid),vhealth); return (1000 - vhealth); }
Hope it works , did only test it for warnings/errors.
Didnt test it, so hope it works
Edit others were faster as me, anyways i guess this function works then because that other guy says the same.
|
C:\Users\Desktop\DeathRace0.3b\gamemodes\DR.pwn(36 7) : error 017: undefined symbol "GetVehicleDamage"
C:\Users\Desktop\DeathRace0.3b\gamemodes\DR.pwn(37 1) : error 029: invalid expression, assumed zero
C:\Users\Desktop\DeathRace0.3b\gamemodes\DR.pwn(37 1) : error 017: undefined symbol "GetVehicleDamage"
C:\Users\Desktop\DeathRace0.3b\gamemodes\DR.pwn(37 5) : warning 213: tag mismatch
C:\Users\Desktop\DeathRace0.3b\gamemodes\DR.pwn(37 7) : warning 225: unreachable code
Re: repair vehicle question! :D -
[XST]O_x - 03.09.2010
pawn Код:
if (strcmp("/fix", cmdtext, true, 10) == 0)
{
if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,RED,"You are not driving in any vehicle!");
new Float:vHealth,cost;
for(new i = 0; i < (1000 - (GetVehicleHealth(GetPlayerVehicleID(playerid),vHealth))); i += 3)
{
if(i - 1000 == 0) break; //If vehicle health is 1000
cost = i;
}
if(GetPlayerMoney(playerid) < cost) return SendClientMessage(playerid,RED,"You don't have enough money to fix your vehicle.");
SetVehicleHealth(GetPlayerVehicleID(playerid),1000);
GivePlayerMoney(playerid,GetPlayerMoney(playerid) - cost);
SendClientMessage(playerid,RED,"You have fixed your vehicle!");
}
Try this.
It adds 3 dollars for each 1% of car health. Examples:
If a car's health is 900, 1000-900 = 100, therefore the price would be $300.
If a car's health is 400, 1000-400 = 600, therefore the price would be $1,800.
If a car's health is 3, 1000-3 = 997, therefore the price would be $2,991.
If a car's health is -1,1000- -1 = 1001, therefore the price would be $3003. (No,that one won't happen).
Re: repair vehicle question! :D -
WillyP - 03.09.2010
Quote:
Originally Posted by [XST]O_x
pawn Код:
if (strcmp("/fix", cmdtext, true, 10) == 0) { if(GetPlayerState(playerid) != PLAYER_STATE_DRIVER) return SendClientMessage(playerid,RED,"You are not driving in any vehicle!"); new Float:vHealth,cost; for(new i = 0; i < (1000 - (GetVehicleHealth(GetPlayerVehicleID(playerid),vHealth))); i += 3) { if(i - 1000 == 0) break; //If vehicle health is 1000 cost = i; } if(GetPlayerMoney(playerid) < cost) return SendClientMessage(playerid,RED,"You don't have enough money to fix your vehicle."); SetVehicleHealth(GetPlayerVehicleID(playerid),1000); GivePlayerMoney(playerid,GetPlayerMoney(playerid) - cost); SendClientMessage(playerid,RED,"You have fixed your vehicle!"); }
Try this.
|
thanks man!