PDA

View Full Version : Search and replace string


Jstylezzz
07/05/2012, 12:06 PM
Hi everyone,

I made something a few mins ago, that changes your name, but the problem is, that the Vehicle system i have, looks to your name and check if it's the same as in the vehiclefile.(system uses fread)

What i want to do here, is create a function that loops trough the folder, searches for the name the person has, and replaces it with the given name.

Like this:


GetPlayerName(playerid)//in my case Jari_Johnson
newname//and replaces it with this


I hope someone knows how to do this :)

Thanks in advance
((I've searched very good, but i couldn't find anything that explained it very good..))

Jonny5
07/05/2012, 12:25 PM
you need to tell your file system,

raw files? INI? ect.
then someone can help.

Jstylezzz
07/05/2012, 12:45 PM
you need to tell your file system,

raw files? INI? ect.
then someone can help.

i did, look to this sentence, at the total end ;)


looks to your name and check if it's the same as in the vehiclefile.(system uses fread)

Jstylezzz
07/05/2012, 02:12 PM
There's more to a file system than a single function - file formats, naming schemes etc. Looping through files is basically ALWAYS the worst option because it is VERY slow. I'd suggest maintaining some form of index for players and their vehicles, or using a file system which doesn't rely on names (which are entirely variable).

So, maybe something that the players have to register their vehicle, or that it registers itself, and use one single file or something?

And, isn't it easier to use MYSQL? I heard that with mysql much things are easier/faster.