SA-MP Forums Archive
Can't figure out how to use strmid properly. - 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: Can't figure out how to use strmid properly. (/showthread.php?tid=404937)



Can't figure out how to use strmid properly. - scriptit - 04.01.2013

Hello.

Код:
	new ID,dest[32];
	new src[32] = "/tocar 20";
	strmid(dest,src,6,strlen(dest));
	sscanf(dest, "i", ID);
	printf("tele id: '%s' '%d'",dest,ID);
Running this code shows that strmid copies nothing to destination string therefore sscanf cant work. However if I switch dest and src then dest will be full string. Could anyone point me out how can I copy just a number from that string?


Re: Can't figure out how to use strmid properly. - Vince - 04.01.2013

You know, you can tell sscanf to skip the string literal.

pawn Код:
sscanf(src, "'/tocar 'd", ID);



Re: Can't figure out how to use strmid properly. - Grim_ - 04.01.2013

That is because you are telling the function to end writing at index 0 (as strlen(dest) will return 0, as it hasn't been initialized). You want to write the string length of src instead.

https://sampwiki.blast.hk/wiki/Strmid