SA-MP Forums Archive
[Tutorial] How to make an basic Fuel system - 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: Tutorials (https://sampforum.blast.hk/forumdisplay.php?fid=70)
+---- Thread: [Tutorial] How to make an basic Fuel system (/showthread.php?tid=169284)

Pages: 1 2


Re: How to make an basic Fuel system - [RA]Bill - 22.08.2010

wouldn't creating a text-draw on player spawn make a new one every time someone spawned so why not make it on the filter-script int with a loop or make one when they join and then delete when they or leave?


Re: How to make an basic Fuel system - Vince - 22.08.2010

Improvement: This
pawn Code:
for(new i=0;i<MAX_VEHICLES;i++) {
        fuel[i] = 100; //sets every car's fuel to 100 in a loop
    }
can just as easily be done in the declaration itself by doing:

pawn Code:
new fuel[MAX_VEHICLES] = {100, 100, ...}; // exactly like this. This will set them all to 100



Re: How to make an basic Fuel system - gamer931215 - 22.08.2010

Quote:
Originally Posted by Vince
View Post
Improvement: This
pawn Code:
for(new i=0;i<MAX_VEHICLES;i++) {
        fuel[i] = 100; //sets every car's fuel to 100 in a loop
    }
can just as easily be done in the declaration itself by doing:

pawn Code:
new fuel[MAX_VEHICLES] = {100, 100, ...}; // exactly like this. This will set them all to 100
I tried that
pawn Code:
new fuel[MAX_VEHICLES] = 100;
But got an error, symbol never declared "fuel" so thats why i did it this way


Re: How to make an basic Fuel system - Vince - 22.08.2010

Read pawn-lang.pdf and scroll to page 64:

Quote:

• Progressive initializers for arrays
The ellipsis operator continues the progression of the initialization constants
for an array, based on the last two initialized elements. The ellipsis operator
(three dots, or “...”) initializes the array up to its declared size.
Examples:
Listing: array initializers
new a[10] = { 1, ... } // sets all ten elements to 1
new b[10] = { 1, 2, ... } // b = 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
new c[8] = { 1, 2, 40, 50, ... } // c = 1, 2, 40, 50, 60, 70, 80, 90
new d[10] = { 10, 9, ... } // d = 10, 9, 8, 7, 6, 5, 4, 3, 2, 1




Re: How to make an basic Fuel system - Nekrus2 - 22.08.2010

Quote:
Originally Posted by gamer931215
View Post
Do you have other textdraws ? here it was bugged with grandlarc's spawn texts (San Fierro, Las Venturas etc)
try to define it if you have (so instead of "TextDrawCreate(..." use new "td_name = TextDrawCreate...)"

And if you reload the filterscript it can be buggedtoo, you can fix that with a loop killing the textdraw for everyone on filterscript exit.

I used the tutorial script for my speedometer which you can find here:
https://sampforum.blast.hk/showthread.php?tid=169469
i havent got any other textdraws and i seen your FS before but i wanted to learn how to make one ... and yours in tutorial seems not work for me ... anyway ... i use and diffrent FS that i found which does not use number but fuel bar and with refuel just on petrol stations so i will stick with that FS for now


Re: How to make an basic Fuel system - Jochemd - 24.08.2010

Nice, I'll use this.


Re: How to make an basic Fuel system - juuleman - 19.10.2010

Thanks, this will help me and alot of other people for sure.


Re: How to make an basic Fuel system - Hurdehack - 16.08.2011

I got a Huge error
:

C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(287) : warning 225: unreachable code
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(287) : warning 217: loose indentation
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(345) : warning 225: unreachable code
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(345) : warning 217: loose indentation
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(35 : warning 217: loose indentation
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(501) : warning 225: unreachable code
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(501) : warning 217: loose indentation
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(501) : error 029: invalid expression, assumed zero
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(501) : error 004: function "S@@_OnPlayerStateChange" is not implemented
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(503) : error 017: undefined symbol "newstate"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(505) : error 017: undefined symbol "playerid"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(507) : error 017: undefined symbol "playerid"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(50 : error 017: undefined symbol "playerid"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(510) : error 017: undefined symbol "playerid"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(514) : warning 225: unreachable code
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(514) : error 029: invalid expression, assumed zero
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(514) : error 004: function "timer_fuel_lower" is not implemented
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(534) : warning 225: unreachable code
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(534) : error 029: invalid expression, assumed zero
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(534) : error 004: function "timer_refuel" is not implemented
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(536) : error 017: undefined symbol "playerid"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(53 : error 017: undefined symbol "playerid"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(539) : error 017: undefined symbol "playerid"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(540) : error 017: undefined symbol "playerid"
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(542) : warning 209: function "S@@_OnFilterScriptInit" should return a value
C:\Users\Christian\Desktop\HurdeHacks Server\pawno\GOOD.pwn(543) : warning 203: symbol is never used: "__Name"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


15 Errors.

help?


Re: How to make an basic Fuel system - Michael_Cuellar - 07.08.2012

I did everything and it compiled but its not showing me how much fuel i have?


Re: How to make an basic Fuel system - Coder_ - 07.08.2012

Quote:
Originally Posted by Michael_Cuellar
View Post
I did everything and it compiled but its not showing me how much fuel i have?
It is random samp bug..


Re: How to make an basic Fuel system - WhiteAngels - 23.06.2014

Can you add the Fuel Station ..?


Re: How to make an basic Fuel system - Le3aT - 26.06.2014

You didn't explain anything


Re: How to make an basic Fuel system - victorcast - 26.06.2014

Thanks for the great tutorial sir!!


Re: How to make an basic Fuel system - AndreiWow - 05.10.2016

It doesnt update while driving and if I leave and re enter the vehicle it will update for few seconds then jump back to 100.


Re: How to make an basic Fuel system - Quinncell - 05.10.2016

Quote:
Originally Posted by AndreiWow
View Post
It doesnt update while driving and if I leave and re enter the vehicle it will update for few seconds then jump back to 100.
The tutorial is 6 years old, what did you expect?