Burgershot
  • Home
  • Members
  • Team
  • Help
  • Search
  • Register
  • Login
  • Home
  • Members
  • Help
  • Search
Burgershot SA-MP Pawn Scripting [Pawn] string manipulation i/o and proper orientation order

 
  • 0 Vote(s) - 0 Average
Pawn string manipulation i/o and proper orientation order
hastlaking
Offline

Burgershot Member
Posts: 25
Threads: 9
Joined: Apr 2019
Reputation: 0
#1
2019-06-12, 11:58 PM
Subject
string manipulation i/o and proper orientation order

Hello community! today i want to share with you a chunk of code written by me, it's main purpose and usage is to mention player's in game globally to know to whom the player is speaking to, the issue i have and concerned about is i cannot proceed further, that is why i have posted here all in relation with pawn scripting section to ask for help from more experienced codders/scripters.

The thing/'s i am concerned about:

Code:
public OnPlayerText(playerid, text[])
{
      switch(text[1])
      {
           case '@': // case the player has inputted symbol '@'
           {
                // sending a client message to the playerid, mainly for its usage.
                // `sscanf` proccssed
                if(sscanf(text, "us[96]", targetid, message))
                {
                     SendClientMessage(playerid, -1, "mention player: \'@\' <id> message");
                     return 0;
                }
           }
      }
      return 0;
}
  • 1. Retrieving both playerid and targetid name - Pending
  • 2. coloring - Ready
  • 3. checking each position on input (after the symbol '@' checking id from 0 to 100) - No idea how to check position
  • 4. formating and sending the message - have it

missing some vital functions and organizing/hooking them.

Best Regard's to everyone
 Hastlaking
jensen
Offline

Burgershot Member
Posts: 2
Threads: 0
Joined: Apr 2019
Reputation: 1
Location: Turkey
#2
2019-06-14, 12:58 AM (This post was last modified: 2019-06-14, 01:07 AM by jensen.)
Try this;

Code:
public OnPlayerText(playerid, text[])
{
    if(text[0] == '@')
    {
        new targetid, message[130], message2[130], targetname[MAX_PLAYER_NAME], name[MAX_PLAYER_NAME];
        strdel(text, 0, 1);
        if(sscanf(text, "us[130]", targetid, message2))
            return SendClientMessage(playerid, -1, "mention player: \'@\' <id> message"), 0;
        if(!IsPlayerConnected(targetid))
            return SendClientMessage(playerid, -1, "This player not connected."), 0;
        GetPlayerName(playerid, name, MAX_PLAYER_NAME);
        GetPlayerName(targetid, targetname, MAX_PLAYER_NAME);
        format(message, sizeof(message), "%s: @%s - %s", name, targetname, message2);
        SendClientMessageToAll(-1, message);
        return 0;
    }
    return 1;
}
Y_Less
Offline

Administrator

Posts: 323
Threads: 16
Joined: Feb 2019
Reputation: 90
#3
2019-06-15, 04:24 PM
Better yet, you can use something like this in sscanf to search for `@` and get the ID at the same time:

Code:
'@'u
« Next Oldest | Next Newest »



  • View a Printable Version
  • Subscribe to this thread
Forum Jump:

© Burgershot - Powered by our Community and MyBB Original Theme by Emerald

Linear Mode
Threaded Mode