[Pawn] Function Get ID by name - 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] Function Get ID by name (/showthread.php?tid=1776) |
Function Get ID by name - GospodinX - 2021-03-16 I have a function IDByName, as the name of the function says I want to get id by player name. Function: Code: IdByName(const name[]) Example: Code: ? new oie = IdByName(name); The function was work perfectly for me for a long time. But now when I have 200 players on my server function get bugged and many times when a player is connected function can't found them.. Have anyone ideas why it happened and how I can improve my function? RE: Function Get ID by name - Y_Less - 2021-03-16 Use sscanf - `u` already does this. RE: Function Get ID by name - Radical - 2021-03-16 Use sscanf as mentioned in the previous post. PHP Code: IdByName(const name[]) RE: Function Get ID by name - GospodinX - 2021-03-16 (2021-03-16, 01:42 PM)Y_Less Wrote: Use sscanf - `u` already does this. Of course I use sscanf,but not for this. For example I have two players in database? GospodinX (online) Gospodin (offline) I want to check is Gospodin online. If I use sscanf u "Gospodin" He will get me id of GospodinX but i dont want it. Am I right? Problem is with player which have smiliar names.. RE: Function Get ID by name - Y_Less - 2021-03-16 Hmm, I see. That should be something sscanf can do - in fact I thought it was. I thought `MATCH_NAME_PARTIAL` would change that, but it seems that just changes between searching at the start of a name and in the middle of a name. I'll have to add `MATCH_NAME_EXACT`. RE: Function Get ID by name - GospodinX - 2021-03-16 (2021-03-16, 04:30 PM)Y_Less Wrote: Hmm, I see.? That should be something sscanf can do - in fact I thought it was.? I thought `MATCH_NAME_PARTIAL` would change that, but it seems that just changes between searching at the start of a name and in the middle of a name.? I'll have to add `MATCH_NAME_EXACT`. It would be useful. So I dont know how to fix it now.. RE: Function Get ID by name - Pinch - 2021-03-17 Code: IdByName(const name[]) ...or... Code: IdByName(const name[]) //Lol ...or... Code: IdByName(const name[]) //Lol v2 |