SA-MP Forums Archive
Help for one small thing.... - 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)
+--- Thread: Help for one small thing.... (/showthread.php?tid=374336)



Help for one small thing.... - Ruffian - 02.09.2012

Need me when player write /setfuelall to refuel all cars in server.

Код:
CMD:setfuel(playerid, params[])
{
	if(!IsAdmin(playerid, 1)) return SendClientMessage(playerid, COLOR_RED, "You are not admin!");
	if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle!");
	new amount, msg[128];
	if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /setfuel [amount]");
	if(amount < 0 || amount > 100) return SendClientMessage(playerid, COLOR_RED, "Invalid amount! (0-100)");
	Fuel[GetPlayerVehicleID(playerid)] = amount;
	format(msg, sizeof(msg), "You have set your vehicle fuel to %d", amount);
	SendClientMessage(playerid, COLOR_WHITE, msg);
	return 1;
}
This is my command for one refuel car.


Re: Help for one small thing.... - [HK]Ryder[AN] - 02.09.2012

pawn Код:
CMD:setfuel(playerid, params[])
{
    if(!IsAdmin(playerid, 1)) return SendClientMessage(playerid, COLOR_RED, "You are not admin!");
    if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_RED, "You are not in a vehicle!");
    new amount, msg[128];
    if(sscanf(params, "d", amount)) return SendClientMessage(playerid, COLOR_GREY, "USAGE: /setfuel [amount]");
    if(amount < 0 || amount > 100) return SendClientMessage(playerid, COLOR_RED, "Invalid amount! (0-100)");
    for(new i = 0; i < MAX_VEHICLES; i++)
        {
                 Fuel[GetPlayerVehicleID(i)] = amount;
        }
    format(msg, sizeof(msg), "You have set your vehicle fuel to %d", amount);
    SendClientMessageToAll(playerid, COLOR_WHITE, msg);
    return 1;
}
I guess this should work.


Re: Help for one small thing.... - Ruffian - 02.09.2012

Thanks i give you rep