Strfind question
#1

Код:
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"));
Reply
#2

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));
Reply
#3

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.
Reply
#4

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?
Reply
#5

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
Reply
#6

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.
Reply
#7

fixed
Reply
#8

Why the hell there is strins function? Also function strmid is a little different than in my code

Код:
strmid(ppl, inputtext, 1, strfind(inputtext, ")"));
Reply
#9

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)