Quote:
Originally Posted by JasonRiggs
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.
|
ty for explaining.
You can use strreplace from strlib.inc, by Slice:
https://sampforum.blast.hk/showthread.php?tid=362764
But the problem is that the variable text[] from OnPlayerText cannot be formated.
So you have to return 0 OnPlayerText and send the message by yourself to the nearby players.
PHP код:
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;
}
Here is a preview: