public OnPlayerText(playerid, text[]) {
if(strfind(text, "hello", true) != -1) strcat(text, "{ff8ed7} *Waving his hand*", sizeof(text));
return 0;
}
|
try this:
PHP код:
|
|
Are you serious? Then it will only work with "Hello *waving his hand*" lol??
I believe strfind would work, Learn how to do it from here.. |
public OnPlayerText(playerid, text[]) {
if(strfind(text, "hello", true) != -1) strcat(text, "{ff8ed7} *Waving his hand*", sizeof(text));
return 0;
}
|
idk what are you trying to say.
look closer at my code, the second time i used strcat, not strfind Код:
public OnPlayerText(playerid, text[]) {
if(strfind(text, "hello", true) != -1) strcat(text, "{ff8ed7} *Waving his hand*", sizeof(text));
return 0;
}
so when you text "hello dude", your message will be shown as "Player says: hello dude *Waving his hand*" https://sampwiki.blast.hk/wiki/Strcat https://sampwiki.blast.hk/wiki/Strfind |
|
He doesn't want it like that mate, look I'll explain it a bit deeper..
He doesn't want anything from "Hello" or "Waving his hand" Alllll what he wants to do is to detect a " * STRING HERE * " he wants two stars with text in between, if that was detected, remove the stars and send the string in purple color which is not like the other text, So not just "Hello" But if -FOR EXAMPLE- I said "Fuck you *shows his middle finger*" I want to send the "Fuck you" in white color, and "shows his middle finger" in purple color but without "*" got it? ALL what you need in it is finding "*" in the player text then omit it and send message to nearby people with color purple(of the text surrounded by stars) easy. |
public OnPlayerText(playerid, text[]){
new string[256];
new name[25];
GetPlayerName(playerid, name, 25);
format(string, 256, "%s says: %s", name, text);
if(strfind(string, "*")) strreplace(string, "*", "{ff00ff}", false, 0, -1, 256);
for(new i; i < MAX_PLAYERS; i++){
new Float:x, Float:y, Float:z;
GetPlayerPos(playerid, x, y, z);
if(IsPlayerInRangeOfPoint(i, 20, x, y, z)) SendClientMessage(i, -1, string);
}
return 0;
}
// extracted from strlib.inc
stock strreplace(string[], const search[], const replacement[], bool:ignorecase = false, pos = 0, limit = -1, maxlength = sizeof(string)) {
if (limit == 0)
return 0;
new
sublen = strlen(search),
replen = strlen(replacement),
bool:packed = ispacked(string),
maxlen = maxlength,
len = strlen(string),
count = 0
;
if (packed)
maxlen *= 4;
if (!sublen)
return 0;
while (-1 != (pos = strfind(string, search, ignorecase, pos))) {
strdel(string, pos, pos + sublen);
len -= sublen;
if (replen && len + replen < maxlen) {
strins(string, replacement, pos, maxlength);
pos += replen;
len += replen;
}
if (limit != -1 && ++count >= limit)
break;
}
return count;
}