CMD:cookies(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin]>=1)
{
new id;
if(sscanf(params, "r", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cookies [Player ID]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000, "This player is not connected!");
new str[64];
format(str, sizeof(str), "%s(%d) has (%d) Cookies.", GetName(id),PlayerInfo[playerid][pCookies]);
SendClientMessage(playerid, COLOR_WHITE, str);
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}
I didn't quite get your problem. Do you want an command that reads the value stored inside a flatfile?
|
CMD:givecookie(playerid, params[]) // CMD for giving somebody a cookie
{
new pid;
new reason[128];
new str[128];
if(sscanf(params, "us[128]", pid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecookie [Player ID] [Reason]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "PlayerID is not connected.");
if(PlayerInfo[playerid][pAdmin]>=2)
{
format(str, sizeof(str), "%s has been granted a cookie by Administrator %s. Reason: (%s)", GetName(pid), GetName(playerid), reason);
SendClientMessageToAll(COLOR_ORANGE, str);
format(str, sizeof(str), "You just gave a cookie to %s.", GetName(pid));
SendClientMessage(playerid, COLOR_GREEN, str);
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
INI_Close(File);
PlayerInfo[pid][pCookies] ++;
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}
CMD:cookies(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin]>=1)
{
new id, str[64];
if(sscanf(params, "r", id)) return SendClientMessage(playerid, 0x0, "USAGE: /cookies [Player ID]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000, "This player is not connected!");
format(str, sizeof(str), "%s(%d) has (%d) Cookies.", GetName(id), id,PlayerInfo[playerid][pCookies]);
SendClientMessage(playerid, 0x0, str);
}
else SendClientMessage(playerid, 0x0, "You're not authorized to use this command.");
return 1;
}
//@ cookies
format(str, sizeof(str), "%s(%d) has (%d) Cookies.", GetName(id),PlayerInfo[playerid][pCookies]);
// --> PlayerInfo[playerid][pCookies]
//So I guess you are checking your cookies not the target's cookies?
//(%s), (%d), and (%d)
//in the format there are only : GetName(id), PlayerInfo[playerid][pCookies]
//as i know getname returns the name not also the id
//@ givecookie
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
//Your giving it to yourself, not pid.
CMD:cookies(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin]>=1)
{
new id, str[64];
if(sscanf(params, "r", id)) return SendClientMessage(playerid, 0x0, "USAGE: /cookies [Player ID]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000, "This player is not connected!");
format(str, sizeof(str), "%s(%d) has (%d) Cookies.", GetName(id), id,PlayerInfo[id][pCookies]);
SendClientMessage(playerid, 0x0, str);
}
else SendClientMessage(playerid, 0x0, "You're not authorized to use this command.");
return 1;
}
INI_WriteInt(File,"Cookies",PlayerInfo[playerid][pCookies]);
INI_Close(File);
PlayerInfo[pid][pCookies] ++;
PlayerInfo[pid][pCookies] ++;
INI_WriteInt(File,"Cookies",PlayerInfo[pid][pCookies]);
INI_Close(File);
CMD:mycookies(playerid, params[])
{
new cstring[64];
format(cstring, sizeof(cstring), "You have %d Cookies.", PlayerInfo[playerid][pCookies]);
SendClientMessage(playerid, COLOR_WHITE, cstring);
return 1;
pawn Код:
|
CMD:givecookie(playerid, params[]) // CMD for giving somebody a cookie
{
new pid;
new reason[128];
new str[128];
if(sscanf(params, "us[128]", pid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /givecookie [Player ID] [Reason]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "PlayerID is not connected.");
if(PlayerInfo[playerid][pAdmin]>=2)
{
format(str, sizeof(str), "%s has been granted a cookie by Administrator %s. Reason: (%s)", GetName(pid), GetName(playerid), reason);
SendClientMessageToAll(COLOR_ORANGE, str);
format(str, sizeof(str), "You just gave a cookie to %s.", GetName(pid));
SendClientMessage(playerid, COLOR_GREEN, str);
new INI:File = INI_Open(UserPath(playerid));
PlayerInfo[pid][pCookies] ++;
INI_WriteInt(File,"Cookies",PlayerInfo[pid][pCookies]);
INI_Close(File);
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}
CMD:resetcookies(playerid, params[])
{
new pid;
new reason[128];
new str[128];
if(sscanf(params, "us[128]", pid, reason)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /resetcookies [Player ID] [Reason]");
if(!IsPlayerConnected(pid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: Player is not connected");
if(PlayerInfo[playerid][pAdmin]>=2)
{
format(str, sizeof(str), "Administrator %s has reset %s's Cookies. Reason: (%s)", GetName(playerid), GetName(pid), reason);
SendClientMessageToAll(COLOR_ORANGE, str);
format(str, sizeof(str), "You just reset %s's Cookies.", GetName(pid));
SendClientMessage(playerid, COLOR_GREEN, str);
PlayerInfo[pid][pCookies] = 0;
}
else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
return 1;
}
CMD:cookies(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin]>=1)
{
new id, str[64];
if(sscanf(params, "r", id)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /cookies [Player ID]");
if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFF0000, "This player is not connected!");
format(str, sizeof(str), "%s(%d) has (%d) Cookies.", GetName(id), id,PlayerInfo[playerid][pCookies]);
SendClientMessage(playerid, 0x0, str);
}
else SendClientMessage(playerid, 0x0, "You're not authorized to use this command.");
return 1;
}
new INI:File = INI_Open(UserPath(playerid)); // Opening the admin's file ? Should be ' INI_Open( UserPath( pid ) ); '
PlayerInfo[pid][pCookies] ++;
INI_WriteInt(File,"Cookies",PlayerInfo[pid][pCookies]);
INI_Close(File);