Ammo problem
#1

Hello,

How can i fix that my ammo will save ? if i use /givegun it will give the player the weapon with 60 ammo, but when the player going to relog, the ammo is set to unlimited.
Reply
#2

Anyone ?
Reply
#3

This is scripting help, not how to script...

You'll need to make various sections of code, first checking what gun they got given, how many bullets, and then, when they shoot, they need to track the amount they will have from there.

Once you've lined that up, you need a variable that is saved (Being weapon, and ammo) to the userfile on the player ending up disconnected.


You really can't simply state what you're wanting and get it handed to you, for this, you need to read up and learn to code a bit more.


It's also not accurate, even though other servers have put it on, fact is they have many years of scripting work behind them.
Reply
#4

You need to save the ammo to a database. It is up to you to decide what type of database you would want to use. It could be MySQL, SQLite, INI, etc.

There are lot of tutorials at the tutorial section that teach you how to use MySQL, SQLite,....
Reply
#5

Quote:
Originally Posted by Yashas
Посмотреть сообщение
You need to save the ammo to a database.
Saving to a database is ONE method of doing it, but you could more easily do it in file form, without any extra need to learn more coding.

You don't NEED to put it in a database, as we're dealing with variables and saving... None of which REQUIRE a database.


Just because big servers use MySQL, and many here are proficient in it, doesn't mean you need to recommend it to anyone.

After all, how much code do you know he has? How much skill is he showing? Do you even know what setup he has currently?
Reply
#6

I did mention INI too in my suggestions.

Quote:

we're dealing with variables and saving

You still need some sort of database since the server side variables reset after a restart/shutdown.
Reply
#7

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Saving to a database is ONE method of doing it, but you could more easily do it in file form, without any extra need to learn more coding.

You don't NEED to put it in a database, as we're dealing with variables and saving... None of which REQUIRE a database.


Just because big servers use MySQL, and many here are proficient in it, doesn't mean you need to recommend it to anyone.

After all, how much code do you know he has? How much skill is he showing? Do you even know what setup he has currently?
INI is also one form of database and i would never use INI for a regular loading/saving purpose. You can run queries which will do the work in milliseconds where as file systems are way too much slower and old fashioned.

Basic SQL can be learned in few hours i guess, moreover there are some includes which doesn't require the user with SQL knowledge.

OT: You must go through tutorials section and study about SQLITE as per my recommendation.
Reply
#8

Fact is without any code from him, and you suggesting that simple "You use a database" without addressing ANYTHING on HOW TO GET/WRITE the info, is stupid.


If I gave you a text file with crap in it, does that make it a database? No...


If I write a file, from the server, to a file, does that make it a database? No, it remains a file.


Quote:
Originally Posted by Gammix
Посмотреть сообщение
OT: You must go through tutorials section and study about SQLITE as per my recommendation.
Didn't see you recommend that in here at all, and no matter of sending him to a tutorial for +rep, doesn't make them able to understand where and how to use it.


After all, does any SQLite tutorial, educate about how to track ammo in a weapon, and to make it accurate?
Reply
#9

Quote:
Originally Posted by Sew_Sumi
Посмотреть сообщение
Fact is without any code from him, and you suggesting that simple "You use a database" without addressing ANYTHING on HOW TO GET/WRITE the info, is stupid.


If I gave you a text file with crap in it, does that make it a database? No...


If I write a file, from the server, to a file, does that make it a database? No, it remains a file.




Didn't see you recommend that in here at all, and no matter of sending him to a tutorial for +rep, doesn't make them able to understand where and how to use it.


After all, does any SQLite tutorial, educate about how to track ammo in a weapon, and to make it accurate?
Ironically, you did the same for +rep.

I am not going to spoon feed, there are good number of tutorials about SQL which can be sufficient enough to write a weapon ammo saving code.

Your last line wasn't relevant at all, Getting weapon ammo is a different aspect than from saving it in a database.
You could simply do GetPlayerAmmo, is it accurate?
Reply
#10

Quote:
Originally Posted by Gammix
Посмотреть сообщение
Ironically, you did the same for +rep.
It was a fucking joke in that thread... Ironically it went over your head.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)