Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- stock convertValue(playerid, value[])
- {
- new
- identifier[2],
- firstIndex[2],
- convertedValue;
- new string[126];
- // Check if string contains letters, and assign them to new variable.
- if(!isNumeric(value)) {
- // Check if first index is integer.
- strmid(firstIndex, value, 0, 1);
- if(!isNumeric(firstIndex))
- return SendClientMessage(playerid, -1, "Blogi parametrai.");
- // Check if string contain letter in bad position.
- for(new i = 0; i < sizeof(letterList); i++)
- if(strfind(value, letterList[i], true) != -1 && strfind(value, letterList[i], true) != strlen(value))
- return SendClientMessage(playerid, -1, "Raidė ne vietoje.");
- // Slice last indexed key from string.
- strmid(identifier, value, strlen(value) - 1, strlen(value));
- if(strcmp(identifier, "m") && strcmp(identifier, "k"))
- return SendClientMessage(playerid, -1, "Blogai nurodyta raidė.");
- new multiplier;
- if(!strcmp(identifier, "m"))
- multiplier = 1000000;
- else
- multiplier = 1000;
- convertedValue = strval(value) * multiplier;
- // Check if string contains "," or ".", and if contains ",", replace it with ".", so we can handle it as a float.
- new indexOf = strfind(value, ".", true);
- if(indexOf != -1) {
- strdel(value, indexOf, indexOf + 1);
- strins(value, ".", indexOf, 1);
- new Float:convertedFloatValue = floatstr(value) * multiplier;
- convertedValue = floatround(convertedFloatValue, floatround_ceil);
- }
- } else convertedValue = strval(value);
- format(string, sizeof string, "7. Return value: %d", convertedValue);
- SendClientMessage(playerid, -1, string);
- /*if(PlayerDB[playerid][MoneyInPocket] < convertedValue)
- return ErrorMsg(playerid,"* Neturite tiek pinigų.");*/
- if(convertedValue > 999999999 || convertedValue < 500)
- return SendClientMessage(playerid, -1, "Netinkama suma.");
- return convertedValue;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement