Kaczmi

ChangeIDToName

Mar 18th, 2012
282
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. stock ChangeIdToName(text[])
  2. {
  3. new
  4. pos = -1;
  5.  
  6. while((pos = strfind(text,"ID",true)) != -1)
  7. {
  8. if(!text[pos+2]) continue;
  9. new
  10. noa = 2,
  11. str[4],
  12. id,
  13. ch;
  14.  
  15. while((ch = text[pos+noa]) && ch <= '9' && ch >= '0' && noa < 5)
  16. {
  17. noa++;
  18. }
  19. if(noa == 2) continue;
  20. strmid(str,text,pos+2,pos+noa);
  21. id = strval(str);
  22. if(IsPlayerConnected(id))
  23. {
  24. new
  25. name[MAX_PLAYER_NAME];
  26.  
  27. GetPlayerName(id,name,sizeof(name));
  28. strdel(text,pos,pos+noa);
  29. strins(name,text,pos,strlen(text));
  30. }
  31. else
  32. {
  33. strdel(text,pos-1,pos+noa);
  34. }
  35.  
  36. }
  37. }
  38.  
  39. public OnPlayerText(playerid,text[])
  40. {
  41. ChangeIdToName(text);
  42. SendPlayerMessageToAll(playerid,text);
  43. return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment