[FilterScript] @ID
#1

Hi, I invented this thing to Sampo that when the server is the player whose name is more than 15 words then you type in chat @ ID .... ID that player you want is to show you the name ...

Code:
public OnPlayerText(playerid, text[])
{
  new string[128];
  format(string, sizeof(string), "%s", text);
  for (new i; i < 128; i++) {
    if (string[i] == '@') {
      if ((string[i + 1] > 47) && (string[i + 1] < 58)) {
      	new id = strval(string[i + 1]);
        if (id <= 500) {
   	  if (IsPlayerConnected(id)) {
            new menohraca[MAX_PLAYER_NAME];
	    GetPlayerName(id, menohraca, MAX_PLAYER_NAME);
	    new j = (i + 1);
	    while ((j < (i + 5)) && ((string[j] > 47) && (string[j] < 58)))
              j++;
	    strdel(string, i, j);
	    strins(string, menohraca, i, 128);
    	  } else {
	    SendClientMessage(playerid, 0xFF0000FF, "Zlй ID");
	    return 0;
	  }
        } else {
	  SendClientMessage(playerid, 0xFF0000FF, "Zlй ID");
	  return 0;
	}
      }
    }
  }
  SendPlayerMessageToAll(playerid, string);
  return 0;
}
Reply
#2

It's more like a snippet so post here https://sampforum.blast.hk/showthread.php?tid=281
Reply
#3

Can you explain how it does work if it's possible? I stuck in the
pawn Code:
if ((string[i + 1] > 47) && (string[i + 1] < 58))
part.
Reply
#4

Quote:
Originally Posted by ]Rafaellos[
View Post
Can you explain how it does work if it's possible? I stuck in the
pawn Code:
if ((string[i + 1] > 47) && (string[i + 1] < 58))
part.
Yeah ... im also stuck here ...
Reply
#5

This is a very bad way of doing this, you should create a "replace string" stock. And all you have to do is place the stock name with its parameters under OnPlayerText or even /pm.

Example:
pawn Code:
CMD:pm(playerid, params[])
{
    ReplaceString(string, GetName(id), params);
    return 1;
}
Chatbox: Hello @2, @3, @4 & @5!
Print out: SickAttack (1): Hello Kevin, John, Luis & Victoria!
Reply
#6

Its a good idea, but i cant make it work.
Code:
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(1) : warning 235: public function lacks forward declaration (symbol "OnPlayerText")
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(4) : error 017: undefined symbol "format"
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(4) : warning 202: number of arguments does not match definition
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(4) : warning 202: number of arguments does not match definition
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(4) : warning 202: number of arguments does not match definition
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(8) : error 017: undefined symbol "strval"
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(10) : error 017: undefined symbol "IsPlayerConnected"
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(11) : error 017: undefined symbol "MAX_PLAYER_NAME"
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(11) : error 009: invalid array size (negative, zero or out of bounds)
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(11) : error 036: empty statement
C:\Users\Rodrigo\Desktop\***\filterscripts\Untitled.pwn(11) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


7 Errors.
PD: if i put it on my GameMode, the Pawno stop's working
Reply
#7

Quote:
Originally Posted by ]Rafaellos[
View Post
Can you explain how it does work if it's possible? I stuck in the
pawn Code:
if ((string[i + 1] > 47) && (string[i + 1] < 58))
part.
It could be written like this as well, which is a bit clearer:

pawn Code:
if('0' <= string[i + 1] <= '9')
It simply checks if the character is a number.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)