SA-MP Forums Archive
Search and replace string - 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)
+--- Thread: Search and replace string (/showthread.php?tid=340426)



Search and replace string - Jstylezzz - 07.05.2012

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:

pawn Код:
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..))


Re: Search and replace string - Jonny5 - 07.05.2012

you need to tell your file system,

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


Re: Search and replace string - Jstylezzz - 07.05.2012

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
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
Quote:
Originally Posted by Jari_Johnson
looks to your name and check if it's the same as in the vehiclefile.(system uses fread)



Re: Search and replace string - Jstylezzz - 07.05.2012

Quote:
Originally Posted by ******
Посмотреть сообщение
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.