Script Request Thread #4

I request cmd /refuel in this script just in place gas station
Quote:

#include <a_samp>
new Text:td_fuel[MAX_PLAYERS];
new Text:td_vhealth[MAX_PLAYERS];
new Text:td_vspeed[MAX_PLAYERS];
new Text:td_box[MAX_PLAYERS];

forward timer_update();
forward timer_refuel(playerid);
new isrefuelling[MAX_PLAYERS] = 0;
new fuel[MAX_VEHICLES];
new Float:max_vhealth[MAX_VEHICLES];

public OnFilterScriptInit()
{
for(new i=0;i<MAX_VEHICLES;i++) {
GetVehicleHealth(i,max_vhealth[i]); //getting max health
fuel[i] = 250 + random(150); //setting fuel for vehicles
}

for(new i=0;i<MAX_PLAYERS;i++) { //setting up all textdraws
td_fuel[i] = TextDrawCreate(476,355,"Fuel:");
td_vhealth[i] = TextDrawCreate(478,376,"Health:");
td_vspeed[i] = TextDrawCreate(478,397,"Speed:");
td_box[i] = TextDrawCreate(478.000000,328.000000,"Vehicle Stats: ~n~~n~~n~~n~");
TextDrawUseBox(td_box[i],1);
TextDrawBoxColor(td_box[i],0x00000066);
TextDrawTextSize(td_box[i],626.000000,21.000000);
TextDrawAlignment(td_fuel[i],0);
TextDrawAlignment(td_vhealth[i],0);
TextDrawAlignment(td_vspeed[i],0);
TextDrawAlignment(td_box[i],0);
TextDrawBackgroundColor(td_fuel[i],0x000000ff);
TextDrawBackgroundColor(td_vhealth[i],0x000000ff);
TextDrawBackgroundColor(td_vspeed[i],0x000000ff);
TextDrawBackgroundColor(td_box[i],0x000000cc);
TextDrawFont(td_fuel[i],1);
TextDrawLetterSize(td_fuel[i],0.699999,2.699999);
TextDrawFont(td_vhealth[i],1);
TextDrawLetterSize(td_vhealth[i],0.699999,2.699999);
TextDrawFont(td_vspeed[i],1);
TextDrawLetterSize(td_vspeed[i],0.699999,2.699999);
TextDrawFont(td_box[i],0);
TextDrawLetterSize(td_box[i],0.699999,2.899999);
TextDrawColor(td_fuel[i],0xffffffff);
TextDrawColor(td_vhealth[i],0xffffffff);
TextDrawColor(td_vspeed[i],0xffffffff);
TextDrawColor(td_box[i],0xffffffff);
TextDrawSetOutline(td_fuel[i],1);
TextDrawSetOutline(td_vhealth[i],1);
TextDrawSetOutline(td_vspeed[i],1);
TextDrawSetOutline(td_box[i],1);
TextDrawSetProportional(td_fuel[i],1);
TextDrawSetProportional(td_vhealth[i],1);
TextDrawSetProportional(td_vspeed[i],1);
TextDrawSetProportional(td_box[i],1);
TextDrawSetShadow(td_fuel[i],1);
TextDrawSetShadow(td_vhealth[i],1);
TextDrawSetShadow(td_vspeed[i],1);
TextDrawSetShadow(td_box[i],10);
}
SetTimer("timer_update",1000,true);
return 1;
}

public OnFilterScriptExit()
{
for(new i=0;i<MAX_PLAYERS;i++) {
TextDrawDestroy(td_fuel[i]);
TextDrawDestroy(td_vhealth[i]);
TextDrawDestroy(td_vspeed[i]);
TextDrawDestroy(td_box[i]);
}
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
if (newstate == PLAYER_STATE_DRIVER || newstate == PLAYER_STATE_PASSENGER)
{

TextDrawSetString(td_fuel[playerid],"Fuel:");
TextDrawSetString(td_vhealth[playerid],"Health:");
TextDrawSetString(td_vspeed[playerid],"Speed:");

TextDrawShowForPlayer(playerid,td_fuel[playerid]);
TextDrawShowForPlayer(playerid,td_vspeed[playerid]);
TextDrawShowForPlayer(playerid,td_vhealth[playerid]);
TextDrawShowForPlayer(playerid,td_box[playerid]);
} else {
TextDrawHideForPlayer(playerid,td_fuel[playerid]);
TextDrawHideForPlayer(playerid,td_vspeed[playerid]);
TextDrawHideForPlayer(playerid,td_vhealth[playerid]);
TextDrawHideForPlayer(playerid,td_box[playerid]);
}
return 1;
}


public OnPlayerCommandText(playerid,cmdtext[]) {

if (!strcmp("/refuel",cmdtext,true,7)) {

if (!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid,0xFFC800FF,"You are not in an vehicle!"); //if a player isnt in a vehicle, it stops here
if (isrefuelling[playerid]) return SendClientMessage(playerid,0xFFC800FF,"You are already refuelling!"); //if a player is already refuelling, it stops here
if (GetPlayerMoney(playerid) - 80 <0) return SendClientMessage(playerid,0xFFC800FF,"You dont have enough money!"); //if a player doesnt have $80 anymore, it stops here
GivePlayerMoney(playerid,-80); //Sets the player's cash -$80
SetCameraBehindPlayer(playerid); //Sets the camera behind the player (looks better because the player will be frozen for a few secs)
TogglePlayerControllable(playerid,0); //freezes the player so he cant drive and refuel at the same time
isrefuelling[playerid] = 1; //setting isrefuelling to 1 so the player cant spam /refuel
TextDrawSetString(td_fuel[playerid],"Refuelling..."); //changing textdraw to /refuel
SetTimerEx("timer_refuel",4500,false,"i",playerid) ; //setting refueltimer
return 1;
}

return 0;
}

public timer_update()
{
for(new i=0;i<MAX_PLAYERS;i++) {
if (isrefuelling[i]) return 0;
new vid = GetPlayerVehicleID(i);
if (GetPlayerVehicleSeat(i) == 0) {
fuel[vid] = fuel[vid] - 2;
if (fuel[vid]<1)
{
fuel[vid] = 0;
RemovePlayerFromVehicle(i);
GameTextForPlayer(i,"~r~You are out of ~w~fuel~r~!",5000,4);
}
}
new string[128];format(string,sizeof string,"Fuel: %i",fuel[vid] /4);
TextDrawSetString(td_fuel[i],string);

new Floatpeed_x,Floatpeed_y,Floatpeed_z,Float:te mp_speed,final_speed,Float:health;

GetVehicleVelocity(vid,speed_x,speed_y,speed_z);
temp_speed = floatsqroot(((speed_x*speed_x)+(speed_y*speed_y))+ (speed_z*speed_z))*136.666667;
final_speed = floatround(temp_speed,floatround_round);
format(string,sizeof string,"Speed: %i",final_speed);
TextDrawSetString(td_vspeed[i],string);

GetVehicleHealth(vid,health);
if (max_vhealth[vid] == 0)//if its an random spawned vehicle
{
fuel[vid] = 400;
GetVehicleHealth(vid,max_vhealth[vid]);
}
health = (((health - max_vhealth[vid]) /max_vhealth[vid]) *100)+ 100;
format(string,sizeof string,"Health: %i",floatround(health,floatround_round));
TextDrawSetString(td_vhealth[i],string);
}
return 1;
}

public timer_refuel(playerid)
{
new vid = GetPlayerVehicleID(playerid);
fuel[vid] = fuel[vid] = 400;
isrefuelling[playerid] = 0;
TextDrawSetString(td_fuel[playerid],"Fuel:100");
TogglePlayerControllable(playerid,1);
}

Reply


Messages In This Thread
Script Request Thread #4 - by dugi - 05.01.2010, 16:07
Re: Script Request Thread #4 - by jameskmonger - 05.01.2010, 16:09
Re: Script Request Thread #4 - by aspire5630 - 05.01.2010, 16:21
Re: Script Request Thread #4 - by [03]Garsino - 05.01.2010, 16:21
Re: Script Request Thread #4 - by [03]Garsino - 05.01.2010, 16:27
Re: Script Request Thread #4 - by Ritchie999 - 05.01.2010, 16:31
Re: Script Request Thread #4 - by Striker_Moe - 05.01.2010, 16:33
Re: Script Request Thread #4 - by ~Dangun! - 05.01.2010, 16:39
Re: Script Request Thread #4 - by [03]Garsino - 05.01.2010, 16:41
Re: Script Request Thread #4 - by Correlli - 05.01.2010, 16:46
Re: Script Request Thread #4 - by Hijolion - 08.01.2010, 18:42
Re: Script Request Thread #4 - by Perker12345 - 08.01.2010, 23:39
Re: Script Request Thread #4 - by PotH3Ad - 09.01.2010, 04:32
Re: Script Request Thread #4 - by Niixie - 09.01.2010, 10:10
Re: Script Request Thread #4 - by bajskorv123 - 09.01.2010, 10:28
Re: Script Request Thread #4 - by Correlli - 09.01.2010, 10:29
Re: Script Request Thread #4 - by bajskorv123 - 09.01.2010, 11:04
Re: Script Request Thread #4 - by Oggle McFoggle - 10.01.2010, 09:44
Re: Script Request Thread #4 - by [03]Garsino - 10.01.2010, 10:21
Re: Script Request Thread #4 - by Finn - 10.01.2010, 10:40
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 17:25
Re: Script Request Thread #4 - by Correlli - 16.01.2010, 17:26
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 17:29
Re: Script Request Thread #4 - by GTAguillaume - 16.01.2010, 17:34
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 17:46
Re: Script Request Thread #4 - by bajskorv123 - 16.01.2010, 18:25
Re: Script Request Thread #4 - by GTAguillaume - 16.01.2010, 19:16
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 19:53
Re: Script Request Thread #4 - by GTAguillaume - 16.01.2010, 20:02
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 20:39
Re: Script Request Thread #4 - by GTAguillaume - 16.01.2010, 20:42
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 20:46
Re: Script Request Thread #4 - by GTAguillaume - 16.01.2010, 20:48
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 20:56
Re: Script Request Thread #4 - by manunited1878 - 16.01.2010, 20:58
Re: Script Request Thread #4 - by GTAguillaume - 16.01.2010, 21:30
Re: Script Request Thread #4 - by GTAguillaume - 16.01.2010, 21:45
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 22:00
Re: Script Request Thread #4 - by GTAguillaume - 16.01.2010, 22:33
Re: Script Request Thread #4 - by Fedee! - 16.01.2010, 23:45
Re: Script Request Thread #4 - by chriswilson - 13.03.2010, 15:54
Re: Script Request Thread #4 - by Scenario - 13.03.2010, 18:07
Re: Script Request Thread #4 - by bajskorv123 - 13.03.2010, 18:49
Re: Script Request Thread #4 - by bartje01 - 14.03.2010, 07:11
Re: Script Request Thread #4 - by MrIncredible - 14.03.2010, 07:18
Re: Script Request Thread #4 - by Scenario - 14.03.2010, 07:40
Re: Script Request Thread #4 - by MrIncredible - 14.03.2010, 07:41
Re: Script Request Thread #4 - by Lajko1 - 14.03.2010, 08:44
Re: Script Request Thread #4 - by Scenario - 14.03.2010, 08:46
Re: Script Request Thread #4 - by Lajko1 - 14.03.2010, 08:49
Re: Script Request Thread #4 - by Scenario - 14.03.2010, 08:50
Re: Script Request Thread #4 - by Lajko1 - 14.03.2010, 09:01
Re: Script Request Thread #4 - by Lajko1 - 14.03.2010, 11:42
Re: Script Request Thread #4 - by manunited1878 - 14.03.2010, 13:07
Re: Script Request Thread #4 - by Lajko1 - 14.03.2010, 13:23
Re: Script Request Thread #4 - by manunited1878 - 14.03.2010, 13:35
Re: Script Request Thread #4 - by Andy_McKinley - 14.03.2010, 15:52
Re: Script Request Thread #4 - by Lajko1 - 14.03.2010, 16:58
Re: Script Request Thread #4 - by Postalityjr - 14.03.2010, 17:01
Re: Script Request Thread #4 - by deather - 14.03.2010, 17:25
Re: Script Request Thread #4 - by Correlli - 25.03.2010, 12:59
Re: Script Request Thread #4 - by Denasdc - 25.03.2010, 17:36
Re: Script Request Thread #4 - by cozza123456 - 25.03.2010, 17:47
Re: Script Request Thread #4 - by cozza123456 - 25.03.2010, 21:55
Re: Script Request Thread #4 - by biltong - 26.03.2010, 15:29
Re: Script Request Thread #4 - by bajskorv123 - 26.03.2010, 17:45
Re: Script Request Thread #4 - by bajskorv123 - 26.03.2010, 22:10
Re: Script Request Thread #4 - by Denasdc - 26.03.2010, 23:06
Re: Script Request Thread #4 - by jamesbond007 - 27.03.2010, 09:43
Re: Script Request Thread #4 - by jasbroek - 27.03.2010, 13:30
Re: Script Request Thread #4 - by biltong - 11.04.2010, 13:44
Re: Script Request Thread #4 - by rbN. - 11.04.2010, 13:45
Re: Script Request Thread #4 - by Awerop - 11.04.2010, 18:16
Re: Script Request Thread #4 - by Vialpando - 12.04.2010, 18:20
Re: Script Request Thread #4 - by ruckfules99 - 14.04.2010, 00:58
Re: Script Request Thread #4 - by biltong - 14.04.2010, 12:33
Re: Script Request Thread #4 - by ruckfules99 - 14.04.2010, 13:29
Re: Script Request Thread #4 - by Roperr - 14.04.2010, 13:52
Re: Script Request Thread #4 - by tooomi - 14.04.2010, 17:53
Re: Script Request Thread #4 - by Thrarod - 14.04.2010, 18:08
Re: Script Request Thread #4 - by rohan234 - 30.05.2010, 14:49
Re: Script Request Thread #4 - by Flashy - 30.05.2010, 16:41
Re: Script Request Thread #4 - by rohan234 - 30.05.2010, 17:30
Re: Script Request Thread #4 - by deather - 31.05.2010, 03:05
Re: Script Request Thread #4 - by Carvino - 31.05.2010, 05:47
Re: Script Request Thread #4 - by FLoRyN[RO] - 31.05.2010, 17:41
Re: Script Request Thread #4 - by Naxix - 01.06.2010, 20:27
Re: Script Request Thread #4 - by goantonio101 - 02.06.2010, 00:00
Re: Script Request Thread #4 - by FLoRyN[RO] - 02.06.2010, 10:59
Re: Script Request Thread #4 - by dolcegabana - 02.06.2010, 13:53
Re: Script Request Thread #4 - by Badman - 02.06.2010, 14:20
Re: Script Request Thread #4 - by damiantof7 - 02.06.2010, 14:23
Re: Script Request Thread #4 - by Correlli - 02.06.2010, 15:11
Re: Script Request Thread #4 - by [HiC]TheKiller - 02.06.2010, 19:59
Re: Script Request Thread #4 - by rohan234 - 02.06.2010, 20:29
Re: Script Request Thread #4 - by DriftboyZ - 02.06.2010, 20:39
Re: Script Request Thread #4 - by (SF)Noobanatior - 03.06.2010, 06:11
Re: Script Request Thread #4 - by DriftboyZ - 03.06.2010, 06:41
Re: Script Request Thread #4 - by Badman - 03.06.2010, 08:23
Re: Script Request Thread #4 - by FLoRyN[RO] - 03.06.2010, 11:36
Re: Script Request Thread #4 - by ViruZZzZ_ChiLLL - 11.06.2010, 12:46
Re: Script Request Thread #4 - by [RO]Madalin2009 - 11.06.2010, 13:16
Re: Script Request Thread #4 - by FLoRyN[RO] - 11.06.2010, 14:22
Re: Script Request Thread #4 - by Biscottinis - 11.06.2010, 14:54
Re: Script Request Thread #4 - by [RO]Madalin2009 - 11.06.2010, 18:16
Re: Script Request Thread #4 - by Rosco_Rich - 11.06.2010, 20:06
Re: Script Request Thread #4 - by Visualbr - 12.06.2010, 00:05
Re: Script Request Thread #4 - by Johndaone - 12.06.2010, 03:17
Re: Script Request Thread #4 - by jameskmonger - 12.06.2010, 06:51
Re: Script Request Thread #4 - by Ihsan_Cingisiz - 12.06.2010, 07:54
Re: Script Request Thread #4 - by RedCrownX - 15.07.2010, 06:06
Re: Script Request Thread #4 - by ikey07 - 15.07.2010, 06:54
Re: Script Request Thread #4 - by RedCrownX - 15.07.2010, 06:57
Re: Script Request Thread #4 - by Nee - 15.07.2010, 10:00
Re: Script Request Thread #4 - by (SF)Noobanatior - 15.07.2010, 10:31
Re: Script Request Thread #4 - by MWF2 - 15.07.2010, 14:50
Re: Script Request Thread #4 - by cca - 16.07.2010, 02:27
Re: Script Request Thread #4 - by Rokys081 - 16.07.2010, 18:05
Re: Script Request Thread #4 - by ikey07 - 16.07.2010, 18:25
Re: Script Request Thread #4 - by ckdut - 16.07.2010, 21:39
Re: Script Request Thread #4 - by tofiffe - 27.08.2010, 14:04
Re: Script Request Thread #4 - by JoeySaladino - 27.08.2010, 19:11
Re: Script Request Thread #4 - by DirtyLilFreak - 28.08.2010, 10:58
Re: Script Request Thread #4 - by Rossi123 - 29.08.2010, 12:43
Re: Script Request Thread #4 - by Miguel - 29.08.2010, 20:47
Re: Script Request Thread #4 - by [Lsrcr]Rafa - 30.08.2010, 12:39
Re: Script Request Thread #4 - by Yamoo - 30.08.2010, 16:12
Re: Script Request Thread #4 - by AndriusZ* - 30.08.2010, 21:44
Re: Script Request Thread #4 - by salut693123 - 30.08.2010, 22:37
Re: Script Request Thread #4 - by Claude - 01.09.2010, 15:29
Re: Script Request Thread #4 - by Str4ndb3rg - 09.09.2010, 17:43
Re: Script Request Thread #4 - by LarzI - 09.09.2010, 18:10
Re: Script Request Thread #4 - by ihatetn931 - 09.09.2010, 18:12
Re: Script Request Thread #4 - by Str4ndb3rg - 09.09.2010, 18:31
Re: Script Request Thread #4 - by ihatetn931 - 09.09.2010, 19:32
Re: Script Request Thread #4 - by Marvin81 - 09.09.2010, 21:28
Re: Script Request Thread #4 - by Scenario - 09.09.2010, 22:52
Re: Script Request Thread #4 - by LarzI - 10.09.2010, 06:15
Re: Script Request Thread #4 - by gin - 10.09.2010, 12:43
Re: Script Request Thread #4 - by Venturas - 10.09.2010, 12:44
Re: Script Request Thread #4 - by Power'Full - 15.09.2010, 23:23
Re: Script Request Thread #4 - by willsuckformoney - 15.09.2010, 23:25
Re: Script Request Thread #4 - by stix - 16.09.2010, 03:03
Re: Script Request Thread #4 - by gondes - 16.09.2010, 05:54
Re: Script Request Thread #4 - by Cypog - 16.09.2010, 12:59
Re: Script Request Thread #4 - by Miricx - 16.09.2010, 13:56
Re: Script Request Thread #4 - by Cameltoe - 16.09.2010, 13:58
Re: Script Request Thread #4 - by Miricx - 16.09.2010, 14:03
Re: Script Request Thread #4 - by Scenario - 16.09.2010, 17:25
Re: Script Request Thread #4 - by Scenario - 16.09.2010, 17:48
Re: Script Request Thread #4 - by LarzI - 16.09.2010, 17:52
Re: Script Request Thread #4 - by Scenario - 16.09.2010, 17:59
Re: Script Request Thread #4 - by gondes - 16.09.2010, 18:21
Re: Script Request Thread #4 - by Power'Full - 16.09.2010, 18:35
Re: Script Request Thread #4 - by stix - 16.09.2010, 18:51
Re: Script Request Thread #4 - by Scenario - 16.09.2010, 19:01
Re: Script Request Thread #4 - by Hiddos - 16.09.2010, 19:27
Re: Script Request Thread #4 - by Scenario - 16.09.2010, 20:15
Re: Script Request Thread #4 - by stix - 16.09.2010, 21:17
Re: Script Request Thread #4 - by Scenario - 16.09.2010, 22:09
Re: Script Request Thread #4 - by Riddy - 26.09.2010, 15:58
Re: Script Request Thread #4 - by Str4ndb3rg - 26.09.2010, 19:19
Re: Script Request Thread #4 - by Str4ndb3rg - 26.09.2010, 19:27
Re: Script Request Thread #4 - by Mauzen - 26.09.2010, 20:35
Re: Script Request Thread #4 - by Luis- - 26.09.2010, 23:19
Re: Script Request Thread #4 - by Str4ndb3rg - 27.09.2010, 15:52
Re: Script Request Thread #4 - by Riddy - 27.09.2010, 18:44
Re: Script Request Thread #4 - by Str4ndb3rg - 28.09.2010, 19:52
Re: Script Request Thread #4 - by ihatetn931 - 28.09.2010, 23:42
Re: Script Request Thread #4 - by Str4ndb3rg - 29.09.2010, 13:47
Re: Script Request Thread #4 - by Lorenc_ - 28.10.2010, 09:57
Re: Script Request Thread #4 - by HippieOnSteriods - 29.10.2010, 11:08
Re: Script Request Thread #4 - by willsuckformoney - 29.10.2010, 11:53
Re: Script Request Thread #4 - by oliver12 - 30.10.2010, 12:14
Re: Script Request Thread #4 - by Brian_Furious - 30.10.2010, 12:44
Re: Script Request Thread #4 - by karakana7 - 30.10.2010, 12:46
Re: Script Request Thread #4 - by WillyP - 30.10.2010, 12:51
Re: Script Request Thread #4 - by karakana7 - 30.10.2010, 13:01
Re: Script Request Thread #4 - by Nero_3D - 30.10.2010, 13:16
Re: Script Request Thread #4 - by Brian_Furious - 30.10.2010, 15:55
Re: Script Request Thread #4 - by Hal - 31.10.2010, 01:32
Re: Script Request Thread #4 - by Febreeze - 31.10.2010, 02:42
Re: Script Request Thread #4 - by m5industries - 31.10.2010, 04:37
Re: Script Request Thread #4 - by Wokie - 31.10.2010, 11:08

Forum Jump:


Users browsing this thread: 9 Guest(s)