[Tutorial] How to make an basic Fuel system
#21

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?
Reply
#22

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
Reply
#23

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
Reply
#24

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

Reply
#25

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
Reply
#26

Nice, I'll use this.
Reply
#27

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

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?
Reply
#29

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

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..
Reply
#31

Can you add the Fuel Station ..?
Reply
#32

You didn't explain anything
Reply
#33

Thanks for the great tutorial sir!!
Reply
#34

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.
Reply
#35

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?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)