Help With OnPlayerText -
AroseKhanNiazi - 19.05.2014
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
Re: Help With OnPlayerText -
rumen98 - 19.05.2014
I think this can be done with multiple coordinates,and many many cases.
Re: Help With OnPlayerText -
AroseKhanNiazi - 19.05.2014
man i got every thing just don't know how to get the $loc form anywhere in players text
Re: Help With OnPlayerText -
NaClchemistryK - 19.05.2014
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.
Re: Help With OnPlayerText -
AroseKhanNiazi - 19.05.2014
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 ??
Re: Help With OnPlayerText -
Parallex - 19.05.2014
Maybe like declaring a variable like this?
pawn Код:
if (text[0] == '$')
{
//Rest of the Code which'll show the location, etcectra.
return 0;
}
Re: Help With OnPlayerText -
AroseKhanNiazi - 19.05.2014
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
Re: Help With OnPlayerText -
NaClchemistryK - 19.05.2014
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?
Re: Help With OnPlayerText -
AroseKhanNiazi - 19.05.2014
no what is r-fs ?? and can some one tell how to work with strins i am not getting it on wiki
Re: Help With OnPlayerText -
NaClchemistryK - 19.05.2014
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..