save text under several conditions - 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: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: save text under several conditions (
/showthread.php?tid=214899)
save text under several conditions -
vardanega - 22.01.2011
Hello! I have a problem:
I want registered 6 names with 60 characters but I also like that those registrations will not be the same: I thought to do a loop.
How do I is not got a clue how to take,
if you could help me with the code?
Thank you for any help!
Vince
Re: save text under several conditions -
hanzen - 22.01.2011
What do you want? Save 6 names to a file or a variable?
Re : save text under several conditions -
vardanega - 22.01.2011
Variable !
AW: save text under several conditions -
Nero_3D - 22.01.2011
Yes you need a loop, just check in it if the name already got added
If it doesnt add the new name to a free space, done
The code below is just an example
pawn Код:
stock AddToData(data[][], input[], i = sizeof data, const size = sizeof data[])
{
if(!input[0]) return 0; //checks if the input is emtpy
new free = -1; //declares free as -1
while((--i) != -1) //A while loop
if(!data[i][0]) free = i; //Checks if the data space is emtpy - necessary because of strcmp
else if(!strcmp(input, data[i], true)) return 0; //Checks if the name is the same
if(free == -1) return -1; //returns -1 if no free space was found
strcat(data[free], input, size); //insert the input in the free data space
return 1; //returns 1 for success
}
Re : save text under several conditions -
vardanega - 22.01.2011
thanks !
Re : save text under several conditions -
vardanega - 22.01.2011
is that you can show me an example of use?
Thanks !
AW: Re : save text under several conditions -
Nero_3D - 22.01.2011
Quote:
Originally Posted by vardanega
is that you can show me an example of use?
Thanks !
|
Just
AddToData(YOUR_VARIABLE_WHICH_IS_6*60, THE_NAME_TO_ADD);
But its just an example if it doesnt work I dont care