Advertisement
mariusqw

Untitled

Apr 1st, 2020
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. stock convertValue(playerid, value[])
  2. {
  3. new
  4. identifier[2],
  5. firstIndex[2],
  6. convertedValue;
  7.  
  8. new string[126];
  9.  
  10. // Check if string contains letters, and assign them to new variable.
  11. if(!isNumeric(value)) {
  12. // Check if first index is integer.
  13. strmid(firstIndex, value, 0, 1);
  14.  
  15. if(!isNumeric(firstIndex))
  16. return SendClientMessage(playerid, -1, "Blogi parametrai.");
  17.  
  18. // Check if string contain letter in bad position.
  19. for(new i = 0; i < sizeof(letterList); i++)
  20. if(strfind(value, letterList[i], true) != -1 && strfind(value, letterList[i], true) != strlen(value))
  21. return SendClientMessage(playerid, -1, "Raidė ne vietoje.");
  22.  
  23. // Slice last indexed key from string.
  24. strmid(identifier, value, strlen(value) - 1, strlen(value));
  25.  
  26. if(strcmp(identifier, "m") && strcmp(identifier, "k"))
  27. return SendClientMessage(playerid, -1, "Blogai nurodyta raidė.");
  28.  
  29. new multiplier;
  30.  
  31. if(!strcmp(identifier, "m"))
  32. multiplier = 1000000;
  33. else
  34. multiplier = 1000;
  35.  
  36. convertedValue = strval(value) * multiplier;
  37.  
  38. // Check if string contains "," or ".", and if contains ",", replace it with ".", so we can handle it as a float.
  39. new indexOf = strfind(value, ".", true);
  40.  
  41. if(indexOf != -1) {
  42. strdel(value, indexOf, indexOf + 1);
  43. strins(value, ".", indexOf, 1);
  44.  
  45. new Float:convertedFloatValue = floatstr(value) * multiplier;
  46. convertedValue = floatround(convertedFloatValue, floatround_ceil);
  47. }
  48. } else convertedValue = strval(value);
  49.  
  50. format(string, sizeof string, "7. Return value: %d", convertedValue);
  51. SendClientMessage(playerid, -1, string);
  52.  
  53. /*if(PlayerDB[playerid][MoneyInPocket] < convertedValue)
  54. return ErrorMsg(playerid,"* Neturite tiek pinigų.");*/
  55.  
  56. if(convertedValue > 999999999 || convertedValue < 500)
  57. return SendClientMessage(playerid, -1, "Netinkama suma.");
  58.  
  59. return convertedValue;
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement