SA-MP Forums Archive
About Strcmp - 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: About Strcmp (/showthread.php?tid=259795)



About Strcmp - Tee - 06.06.2011

I am kinda confused with strcmp and getting the string from a file. I want to know if, I want to get a name from a string and compare it with the variable 'Name' and let it return that it is found, if I would use :

pawn Код:
strcmp(Name,dini_Get(file,"Name"),false,strlen(Name))
Or

pawn Код:
if(strcmp(dini_Get(file,"Name"),Name,false) == 0)
Asuming that in the file, Name=Tee.

I don't really understand the example on wiki samp about getting the string from a textfile and if it's found, would it return the length of the string?


Re: About Strcmp - JaTochNietDan - 06.06.2011

Your code appears to be correct, dini_Get is returning the string in the Name key of the ini file.

So your second example is correct and should work fine, have you tested it?


Re: About Strcmp - Tee - 06.06.2011

I have been using it for quite a while and it works when it feels to. The other thing, if it is from a textfile (like .ini) for it to return found, would i use strval(stringfromvarialbe) or == 0 (as in the example at wiki samp).

String from variable would be 'Name'


Re: About Strcmp - TheGarfield - 06.06.2011

the

strcmp < Compares.


Mode 1:
pawn Код:
if(!strcmp(     dini_Get(file,"Name")     ,      Name,true))

Mode 2:
pawn Код:
if(!strcmp(          Nome,      dini_Get(file,"Name"),true))

the two modes is correct.


Re: About Strcmp - Tee - 06.06.2011

So from a textfile, it does not matter wheather I put strval(stringfromvariable) or == 0?