11.01.2015, 06:31
Hello i made a TextDraw known as Premium Points . but it don't update when i give or take premium points from someone . Following is the codes.
I added the following command in OnPlayerSpawn()
At OnPlayerDisconnet()
Public UpdatePlayer() is following ( i also did the forward for UpdatePlayer)
OnPlayerConnect()
And the following in OnPlayerDisconnect()
Following is the commands of giving and taking premium points.
Taking Premium points:
(I know there is some mistakes in Takepp of format .)
Giving Premium point:
Setting Premium points :
PHP код:
stock load_pp(playerid)
{
Textdraw1 = CreatePlayerTextDraw(playerid,501.000000, 100.000000, "Premium Points: 69");
PlayerTextDrawBackgroundColor(playerid,Textdraw1, -1);
PlayerTextDrawFont(playerid,Textdraw1, 1);
PlayerTextDrawLetterSize(playerid,Textdraw1, 0.320000, 0.799999);
PlayerTextDrawColor(playerid,Textdraw1, 65535);
PlayerTextDrawSetOutline(playerid,Textdraw1, 1);
PlayerTextDrawSetProportional(playerid,Textdraw1, 1);
PlayerTextDrawUseBox(playerid,Textdraw1, 1);
PlayerTextDrawBoxColor(playerid,Textdraw1, 0x00000044);
PlayerTextDrawTextSize(playerid,Textdraw1, 606.000000, 0.000000);
PlayerTextDrawSetSelectable(playerid,Textdraw1, 0);
return 1;
}
PHP код:
PlayerTextDrawShow(playerid, Textdraw1);
PHP код:
PlayerTextDrawHide(playerid, Textdraw1);
PHP код:
public UpdatePlayer()
{
new string[256];
foreach(new i : Player)
{
format(string, 128, "Premium Points: %d", User[i][accountPP]);
PlayerTextDrawSetString(i, Textdraw1, string);
}
return 1;
}
PHP код:
load_pp(playerid);
PHP код:
PlayerTextDrawHide(playerid, Textdraw1);
unloadpp(playerid);
Taking Premium points:
PHP код:
CMD:takepp(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.");
if(User[id][accountPP] < amount) return SendClientMessage(playerid, 0xFF0000FF, "This Player Dont Have That Much Points!");
format(string, 150, "[PREMIUM POINTS] "red"%s has taken %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 lost{%06x}%s "white"premium points of "grey"%d"white".", GetPlayerColor(id) >>> 8, GetName(id), amount);
SendClientMessage(playerid, -1, string);
format(string, 128, "%s take %d Premium Point(s) from %s.", GetName(playerid), amount, GetName(id));
Log("premium.txt", string);
User[id][accountPP] -= amount;
}
else
{
SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
}
return 1;
}
Giving Premium point:
PHP код:
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));
Log("premium.txt", string);
User[id][accountPP] += amount;
}
else
{
SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
}
return 1;
}
PHP код:
CMD:setpremium(playerid, params[])
{
new
string[200],
id,
amount
;
LoginCheck(playerid);
if(User[playerid][accountAdmin] >= 5)
{
if(sscanf(params, "ui", id, amount)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /setpremium [playerid] [points]");
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, 128, "[SET] "white"%s's Premium Point has been set to %d by %s.", GetName(id), amount, GetName(playerid));
SendAMessage(COLOR_RED, string);
format(string, 128, "[SET] "white"An admin has set your premium points to %d.", amount);
SendClientMessage(id, COLOR_YELLOW, string);
format(string, 128, "%s has been premium points set to %d by %s.", GetName(id), amount, GetName(playerid));
Log("admin.txt", string);
User[id][accountPP] = amount;
}
else
{
SendClientMessage(playerid, -1, "» "red"You are not authorized to use this command.");
}
return 1;
}