CMD:givepp(playerid, params[])
{
LoginCheck(playerid);
if(User[playerid][accountAdmin] >= 3)
{
new string[150], id, amount;
if(sscanf(params, "ui", id, amount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givepp [playerid] [amount]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "» "red"Player not connected.");
if(User[id][accountLogged] == false) return SendClientMessage(playerid, -1, "» "red"Player not logged in.");
format(string, 150, "[PREMIUM POINTS] "red"%s has given %s [%d] Premium Points.", GetName(playerid), GetName(id), amount);
SendAMessage(-1, string);
format(string, 150, ""green"[PREMIUM POINTS] "white"You have received "grey"%d "white"premium points from an "red"admin"white".", amount, User[id][accountPP]+amount);
SendClientMessage(id, -1, string);
format(string, 150, "» You have given {%06x}%s "white"premium points of "grey"%d"white".", GetPlayerColor(id) >>> 8, GetName(id), amount);
SendClientMessage(playerid, -1, string);
format(string, 128, "%s received %d Premium Points from %s.", GetName(id), amount, GetName(playerid));
User[id][accountPP] += amount;
return 1;
|
Floats and Integers
Float -> Integer Converting a float to an integer is quite easy, as an integer doesn't have a tag and a float does. All we have to do is change the tag: pawn Код:
pawn Код:
Converting an integer to a Float can be done various ways: pawn Код:
|
|
Floats are a type of tagged variable in PAWN and they are "floating point numbers", hence the name Float. This basically means that they support decimal places, such as 1.2, 1.1, 5.32, 64.21 - where as normal integers (untagged) don't support decimal places.[]
|
CMD:givepp(playerid, params[])
{
LoginCheck(playerid);
if(User[playerid][accountAdmin] >= 3)
{
new string[150], id, Float:amount;//note that Float: is added to make it a float
//in sscanf 'f' is used for floats
if(sscanf(params, "uf", id, amount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /givepp [playerid] [amount]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "» "red"Player not connected.");
if(User[id][accountLogged] == false) return SendClientMessage(playerid, -1, "» "red"Player not logged in.");
//see the line below
if(amount % 0.25 != 0.0)return SendClientMessage(playerid, -1, "» "red"Only amounts that are divisible by 0.25 can be given.");
format(string, 150, "[PREMIUM POINTS] "red"%s has given %s [%d] Premium Points.", GetName(playerid), GetName(id), amount);
SendAMessage(-1, string);
format(string, 150, ""green"[PREMIUM POINTS] "white"You have received "grey"%d "white"premium points from an "red"admin"white".", amount, User[id][accountPP]+amount);
SendClientMessage(id, -1, string);
format(string, 150, "» You have given {%06x}%s "white"premium points of "grey"%d"white".", GetPlayerColor(id) >>> 8, GetName(id), amount);
SendClientMessage(playerid, -1, string);
format(string, 128, "%s received %d Premium Points from %s.", GetName(id), amount, GetName(playerid));
User[id][accountPP] += amount;
return 1;
|
Like this
pawn Код:
|
" is not implemented
if(amount % 0.25 != 0.0)return SendClientMessage(playerid, -1, "» "red"Only amounts that are divisible by 0.25 can be given.");
stock Float:modulus(Float:a, Float:b)
{
while(a > b)
a -= b;
return a;
}
//the if line -->
if(modulus(0.25, amount) != 0.0)return ...