open.mp forum
[Pawn] string manipulation i/o and proper orientation order - Printable Version

+- open.mp forum (https://forum.open.mp)
+-- Forum: SA-MP (https://forum.open.mp/forumdisplay.php?fid=3)
+--- Forum: Pawn Scripting (https://forum.open.mp/forumdisplay.php?fid=10)
+--- Thread: [Pawn] string manipulation i/o and proper orientation order (/showthread.php?tid=651)



string manipulation i/o and proper orientation order - hastlaking - 2019-06-12

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



RE: string manipulation i/o and proper orientation order - jensen - 2019-06-14

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; }



RE: string manipulation i/o and proper orientation order - Y_Less - 2019-06-15

Better yet, you can use something like this in sscanf to search for `@` and get the ID at the same time:



Code:
'@'u