Help With OnPlayerText
#1

How can i define That If An Player Types the text $location anywhere middle of his message it should tell the players location
example a player is at city hall he uses
"I am at $location" it should replace the "$location" with the place he is i got the the names of location just tell me how to do something like that
Reply
#2

I think this can be done with multiple coordinates,and many many cases.
Reply
#3

man i got every thing just don't know how to get the $loc form anywhere in players text
Reply
#4

use the function strfind. It is used to find a string.
https://sampwiki.blast.hk/wiki/Strfind
EDIT: sorry, I meant certain characters in a string.
Reply
#5

i am not getting it i have an variable location that defines players location show how can i replace the text $location with the variable can u give me an example pawn code ??
Reply
#6

Maybe like declaring a variable like this?
pawn Код:
if (text[0] == '$')
{
 //Rest of the Code which'll show the location, etcectra.
return 0;
}
Reply
#7

Quote:
Originally Posted by BenJackster
Посмотреть сообщение
Maybe like declaring a variable like this?
pawn Код:
if (text[0] == '$')
{
 //Rest of the Code which'll show the location, etcectra.
return 0;
}
will this even get if it is in center of the string ??
and how do i replace it
Reply
#8

That code will only see if the first character of the player's text is a "$".
And making codes like that is hard for newbies like me and you. It's complicated. You must first somehow find in which location in the string you find the $location, delete that and replace it using strins.
P.S: Just asking out of curiousity, are you a player of a server called r-fs?
Reply
#9

no what is r-fs ?? and can some one tell how to work with strins i am not getting it on wiki
Reply
#10

lemme give you a list of the functions you need so you can script it yourself. I have my own scripts to take care of, sorry..
strfind, used to find a string. https://sampwiki.blast.hk/wiki/Strfind
strins, used to insert a string. https://sampwiki.blast.hk/wiki/Strins
strdel, used to delete a string.https://sampwiki.blast.hk/wiki/Strdel
a function used to check where a certain character(s) of a string is -- I don't know about that..
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)