Skip to content

Commit

Permalink
Add global file to use in gamemode (#1) + improvements
Browse files Browse the repository at this point in the history
- Add GetPlayerScoreEx, SetPlayerScoreEx
- Change some stocks to publics
  • Loading branch information
MichaelBelgium committed Sep 1, 2017
1 parent 88706f2 commit 766f3d4
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 17 deletions.
Binary file modified filterscripts/MV_cPanel.amx
Binary file not shown.
2 changes: 1 addition & 1 deletion filterscripts/MV_cPanel.pwn
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ public OnPlayerDisconnect(playerid, reason)
{
if(GetPlayerState(playerid) != PLAYER_STATE_NONE)
{
mysql_format(gCon, query, sizeof(query), "UPDATE Players SET Score = %i, Money = %i, Adminlevel = %i, Kills = %i, Deaths = %i, lIP = '%s', OnlineTime = OnlineTime + %i, Warnings = %i WHERE Playername = '%e'", PlayerInfo[playerid][Score], GetPlayerCash(playerid), GetPlayerLevel(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][IP], NetStats_GetConnectedTime(playerid)/1000, PlayerInfo[playerid][Warns], GetPlayerNameEx(playerid));
mysql_format(gCon, query, sizeof(query), "UPDATE Players SET Score = %i, Money = %i, Adminlevel = %i, Kills = %i, Deaths = %i, lIP = '%s', OnlineTime = OnlineTime + %i, Warnings = %i WHERE Playername = '%e'", GetPlayerScoreEx(playerid), GetPlayerCash(playerid), GetPlayerLevel(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], PlayerInfo[playerid][IP], NetStats_GetConnectedTime(playerid)/1000, PlayerInfo[playerid][Warns], GetPlayerNameEx(playerid));
mysql_query(gCon, query, false);

if(IsPlayerVIP(playerid))
Expand Down
10 changes: 4 additions & 6 deletions pawno/include/MV_cPanel/cPanel_Commands.inc
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ CMD:stats(playerid,params[])
format(string, sizeof(string), "Name: %s (ID: %i)\nLevel: %s (%i)\nVIP: %s\nPing: %i\nIP: %s\n\n", GetPlayerNameEx(playerid), playerid, GetPlayerLevelEx(GetPlayerLevel(playerid)), GetPlayerLevel(playerid), IsPlayerVIP(playerid) ? ("yes") : ("no"), GetPlayerPing(playerid), PlayerInfo[playerid][IP]);
strcat(stats, string);

format(string, sizeof(string), "Kills: %i\nDeaths: %i\nScore: %i\nMoney: %i\n\n", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], GetPlayerScore(playerid), GetPlayerCash(playerid));
format(string, sizeof(string), "Kills: %i\nDeaths: %i\nScore: %i\nMoney: %i\n\n", PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], GetPlayerScoreEx(playerid), GetPlayerCash(playerid));
strcat(stats, string);

format(string, sizeof(string), "Online time (session): %s\nOnline time (total): %s\n\n", MsToString(NetStats_GetConnectedTime(playerid),"%1h:%1m:%1s"), MsToString(((NetStats_GetConnectedTime(playerid)/1000)+PlayerInfo[playerid][OnlineTime])*1000,"%1h:%1m:%1s"));
Expand All @@ -43,7 +43,7 @@ CMD:stats(playerid,params[])
format(string, sizeof(string), "Name: %s (ID: %i)\nLevel: %s (%i)\nVIP: %s\nPing: %i\nIP: %s\n\n", GetPlayerNameEx(id), id, GetPlayerLevelEx(GetPlayerLevel(id)), GetPlayerLevel(id), IsPlayerVIP(id) ? ("yes") : ("no"), GetPlayerPing(id), PlayerInfo[id][IP]);
strcat(stats, string);

format(string, sizeof(string), "Kills: %i\nDeaths: %i\nScore: %i\nMoney: %i\n\n", PlayerInfo[id][Kills], PlayerInfo[id][Deaths], GetPlayerScore(id), GetPlayerCash(id));
format(string, sizeof(string), "Kills: %i\nDeaths: %i\nScore: %i\nMoney: %i\n\n", PlayerInfo[id][Kills], PlayerInfo[id][Deaths], GetPlayerScoreEx(id), GetPlayerCash(id));
strcat(stats, string);

format(string, sizeof(string), "Online time (session): %s\nOnline time (total): %s\n", MsToString(NetStats_GetConnectedTime(id),"%1h:%1m:%1s"), MsToString(((NetStats_GetConnectedTime(id)/1000)+PlayerInfo[id][OnlineTime])*1000,"%1h:%1m:%1s"));
Expand Down Expand Up @@ -929,8 +929,7 @@ CMD:setscore(playerid, params[])
if(sscanf(params, "ii", id, score)) return SendClientMessage(playerid, COLOR_RED, "Usage: /setscore [playerid] [score]");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "This player isn't connected");

PlayerInfo[id][Score] = score;
SetPlayerScore(id, PlayerInfo[id][Score]);
SetPlayerScoreEx(id, score);

format(string, sizeof(string), COL_ADMIN_1"-[%s: %s]- "COL_ADMIN_2"set %s's (%i) score to %i", GetPlayerLevelEx(GetPlayerLevel(playerid)), GetPlayerNameEx(playerid), GetPlayerNameEx(id), id, score);
SendClientMessageToAll(-1, string);
Expand Down Expand Up @@ -992,8 +991,7 @@ CMD:setallscore(playerid, params[])
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
if(!IsPlayerConnected(i)) continue;
PlayerInfo[i][Score] = score;
SetPlayerScore(i, PlayerInfo[i][Score]);
SetPlayerScoreEx(i, score);
}

format(string, sizeof(string), COL_ADMIN_1"-[%s: %s]- "COL_ADMIN_2"set everyone's score to %i", GetPlayerLevelEx(GetPlayerLevel(playerid)), GetPlayerNameEx(playerid), score);
Expand Down
30 changes: 20 additions & 10 deletions pawno/include/MV_cPanel/cPanel_Functions.inc
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#define cPanel_func:%0(%1) forward %0(%1); public %0(%1)

ShowPlayerDialogEx(playerid,dialogid)
{
new string[128];
Expand Down Expand Up @@ -41,7 +43,7 @@ ShowPlayerDialogEx(playerid,dialogid)
return 1;
}

SendClientMessageToAdmins(color, message[])
cPanel_func:SendClientMessageToAdmins(color, message[])
{
for(new i = 0, j = GetPlayerPoolSize(); i <= j; i++)
{
Expand Down Expand Up @@ -145,33 +147,41 @@ stock GetPlayerLevelEx(level)
return playerlevel;
}

stock IsPlayerVIP(playerid) return VipInfo[playerid][Duration] != -1;
stock IsPlayerAdminEx(playerid, level) return PlayerInfo[playerid][Adminlevel] >= level;
stock IsPlayerMuted(playerid) return PlayerInfo[playerid][Muted] > 0;
cPanel_func:IsPlayerVIP(playerid) return VipInfo[playerid][Duration] != -1;
cPanel_func:IsPlayerAdminEx(playerid, level) return PlayerInfo[playerid][Adminlevel] >= level;
cPanel_func:IsPlayerMuted(playerid) return PlayerInfo[playerid][Muted] > 0;

stock GivePlayerScore(playerid, score)
cPanel_func:GivePlayerScore(playerid, score)
{
PlayerInfo[playerid][Score] += score;
SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
PlayerInfo[playerid][Score] += score;
SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
}

stock GivePlayerCash(playerid, money)
cPanel_func:SetPlayerScoreEx(playerid, score)
{
PlayerInfo[playerid][Score] = score;
SetPlayerScore(playerid, PlayerInfo[playerid][Score]);
}

cPanel_func:GetPlayerScoreEx(playerid) return PlayerInfo[playerid][Score];

cPanel_func:GivePlayerCash(playerid, money)
{
PlayerInfo[playerid][Money] += money;

ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
}

stock SetPlayerCash(playerid, money)
cPanel_func:SetPlayerCash(playerid, money)
{
PlayerInfo[playerid][Money] = money;

ResetPlayerMoney(playerid);
GivePlayerMoney(playerid, PlayerInfo[playerid][Money]);
}

stock GetPlayerCash(playerid) return PlayerInfo[playerid][Money];
cPanel_func:GetPlayerCash(playerid) return PlayerInfo[playerid][Money];
stock GetPlayerNameEx(playerid)
{
new name[MAX_PLAYER_NAME];
Expand Down
56 changes: 56 additions & 0 deletions pawno/include/MV_cPanel/cPanel_Global.inc
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* This include is only to use in a gamemode next to the MV_cPanel script.
* Warning: about score and money, do not use the default samp functions
* for score use: GivePlayerScore, SetPlayerScoreEx and GetPlayerScoreEx
* same with money: only use GivePlayerCash and SetPlayerCash (and GetPlayerCash)
*/

stock SendClientMessageToAdmins(color, message[])
{
CallRemoteFunction("SendClientMessageToAdmins", "is", color, message);
}

stock IsPlayerVIP(playerid)
{
return CallRemoteFunction("IsPlayerVIP", "i", playerid);
}

stock IsPlayerAdminEx(playerid, level)
{
return CallRemoteFunction("IsPlayerAdminEx", "ii", playerid, level);
}

stock IsPlayerMuted(playerid)
{
return CallRemoteFunction("IsPlayerMuted", "i", playerid);
}

stock GivePlayerScore(playerid, score)
{
CallRemoteFunction("GivePlayerScore", "ii",playerid, score );
}

stock SetPlayerScoreEx(playerid, score)
{
CallRemoteFunction("SetPlayerScoreEx", "ii",playerid, score );
}

stock GivePlayerCash(playerid, money)
{
CallRemoteFunction("GivePlayerCash", "ii", playerid, money);
}

stock SetPlayerCash(playerid, money)
{
CallRemoteFunction("SetPlayerCash", "ii",playerid, money );
}

stock GetPlayerCash(playerid)
{
return CallRemoteFunction("GetPlayerCash", "i",playerid);
}

stock GetPlayerScoreEx(playerid)
{
return CallRemoteFunction("GetPlayerScoreEx", "i", playerid);
}

0 comments on commit 766f3d4

Please sign in to comment.