Strfind question - 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: Strfind question (
/showthread.php?tid=565005)
Strfind question -
Supermaxultraswag - 24.02.2015
Код:
format(str,sizeof(str),"%d\t%s\n", GetPlayerScore(playerid),GetPlayerName(playerid));
Код:
strfind("\\ here, how do I get %d? If i wrote just %d it dont work"));
Re: Strfind question -
ball - 24.02.2015
You can use some characters to know where this score is, example
Код:
format(str,sizeof(str),"(%d)\t%s\n", GetPlayerScore(playerid),GetPlayerName(playerid));
//getting the number
new g[8];
strmid(g, inputtext, 1, strfind(inputtext, ")"));
printf("score: %d", strval(g));
Re: Strfind question -
Supermaxultraswag - 24.02.2015
Quote:
Originally Posted by ball
You can use some characters to know where this score is, example
Код:
format(str,sizeof(str),"(%d)\t%s\n", GetPlayerScore(playerid),GetPlayerName(playerid));
//getting the number
new g[8];
strmid(g, inputtext, 1, strfind(inputtext, ")"));
printf("score: %d", strval(g));
|
umm dont work. print 0, but i had 1500.
Re: Strfind question -
DRIFT_HUNTER - 24.02.2015
In your case you need to find \t and cut out everything in front (thats the score). Than just use strval on that cut out string and you will get value as integer.
But why would you search for something like that if you have GetPlayerScore function?
Re: Strfind question -
Supermaxultraswag - 24.02.2015
Quote:
Originally Posted by DRIFT_HUNTER
In your case you need to find \t and cut out everything in front (thats the score). Than just use strval on that cut out string and you will get value as integer.
|
How do I cut string with strval?
Quote:
Originally Posted by DRIFT_HUNTER
But why would you search for something like that if you have GetPlayerScore function?
|
I have a reasons
Re: Strfind question -
ball - 24.02.2015
Sorry, but for me this works
Код:
public OnGameModeInit()
{
new s[25] = "(28)\tball\n", g[8];
strmid(g, s, 1, strfind(s, ")"));
printf("score: %d", strval(g));
return 1;
}
It shows in the console 28. Show more code.
Re: Strfind question -
Supermaxultraswag - 24.02.2015
fixed
Re: Strfind question -
ball - 24.02.2015
Why the hell there is strins function? Also function strmid is a little different than in my code
Код:
strmid(ppl, inputtext, 1, strfind(inputtext, ")"));
Re: Strfind question -
dominik523 - 24.02.2015
Strins is there so you can insert one string into another at the specific position. It can be very handy.
You are editing some gamemode, right? Check the strmid here:
https://sampwiki.blast.hk/wiki/Strmid