23.10.2012, 21:12
How can i script a Command to give a Player Score, and that only Admins can make it?
dcmd_setscore(playerid,params[])
{
if(AccInfo[playerid][Level] >= 5)
{
new Index;
new tmp[256]; tmp = strtok(params,Index);
new tmp2[256]; tmp2 = strtok(params,Index);
if(!strlen(tmp) || !strlen(tmp2) || !IsNumeric(tmp2)) return
SendClientMessage(playerid, LIGHTBLUE2, "Usage: /setscore [PlayerID] [Score]") &&
SendClientMessage(playerid, orange, "Function: Will set Score of specified player!");
new player1 = strval(tmp);
new score = strval(tmp2);
new string[128];
if(AccInfo[player1][Level] == ServerInfo[MaxAdminLevel] && AccInfo[playerid][Level] != ServerInfo[MaxAdminLevel])
return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID)
{
SendCommandToAdmins(playerid,"SetScore");
format(string, sizeof(string), "|- You have set \"%s's\" Score to '%d' -|",pName(player1),score);
SendClientMessage(playerid,BlueMsg,string);
if(player1 != playerid)
{
format(string,sizeof(string),"|- Administrator \"%s\" has set your Score to '%d' -|", pName(playerid), score);
SendClientMessage(player1,blue,string);
}
return SetPlayerScore(player1, score);
}
else return ErrorMessages(playerid, 2);
}
else return ErrorMessages(playerid, 1);
}
CMD:givescore(playerid,params[])
{
new target,score;
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params,"ud",target,score)) return SendClientMessage(playerid,-1,"USAGE:/givescore [playerid] [score]");
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,"ERROR:Player not connected");
if(score < 0) return SendClientMessage(playerid,-1,"Abusing is not allowed");
SetPlayerScore(playerid,GetPlayerScore(playerid)-score);
SetPlayerScore(target,GetPlayerScore(target)+score);
return 1;
}
CMD:setscore(playerid,params[])
{
new target,score;
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params,"ud",target,score)) return SendClientMessage(playerid,-1,"USAGE:/setscore [playerid] [score]");
if(!IsPlayerConnected(playerid)) return SendClientMessage(playerid,-1,"ERROR:Player not connected");
SetPlayerScore(target,score);
return 1;
}
COMMAND:setscore(playerid,params[])
{
if(PlayerInfo[playerid][AdminLevel] >= LEVEL_setscore)
{
new player, amount;
if(sscanf(params, "rd", player, amount))
{
SendClientMessage(playerid,H_MSG,"Usage: /setscore [ID/Part of Name][Score]");
return 1;
}
if(IsPlayerConnected(player) && player != INVALID_PLAYER_ID)
{
new string[128];
if(player != playerid)
{
format(string,sizeof(string),"Administrator \"%s\" has set your score to %d.", GetName(playerid), amount);
SendClientMessage(player,YELLOW,string);
format(string,sizeof(string),"You set \"%s\'s\" score to %d.",GetName(player));
SendClientMessage(playerid,YELLOW,string);
}
else
{
format(string,sizeof(string),"You have set your score to %d.",amount);
SendClientMessage(playerid,YELLOW,string);
}
SetPlayerScore(player, amount);
}
else
{
SendClientMessage(playerid,RED,"ERROR: Player is not connected");
}
}
else
{
SendClientMessage(playerid, RED, "Not enought permission");
}
return 1;
}
CMD:setscore(playerid,params[]) {
if(PlayerInfo[playerid][Level] >= 5) {
new tmp[256], tmp2[256], Index; tmp = strtok(params,Index), tmp2 = strtok(params,Index);
if(isnull(tmp) || isnull(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playerid, red, "USAGE: /setscore [playerid] [score]");
new player1 = strval(tmp), score = strval(tmp2), string[128];
if(PlayerInfo[player1][Level] == ServerInfo[MaxAdminLevel] && PlayerInfo[playerid][Level] != ServerInfo[MaxAdminLevel]) return SendClientMessage(playerid,red,"ERROR: You cannot use this command on this admin");
if(IsPlayerConnected(player1) && player1 != INVALID_PLAYER_ID) {
format(string, sizeof(string), "You have set \"%s's\" score to '%d' ", pName(player1), score); SendClientMessage(playerid,blue,string);
if(player1 != playerid) { format(string,sizeof(string),"Administrator \"%s\" has set your score to '%d'", pName(playerid), score); SendClientMessage(player1,blue,string); }
return SetPlayerScore(player1, score);
} else return SendClientMessage(playerid,red,"ERROR: Player is not connected");
} else return SendClientMessage(playerid,red,"ERROR: You are not a high enough level to use this command");
}
YCMD:givescore(playerid, params[], help)
{
if(!IsPlayerAdmin(playerid))return SendClientMessage(playerid, -1, "You are not Admin!");
new id, soc, up = GetPlayerScore(playerid);
if(sscanf(params, "ui", id, soc))return SendClientMessage(playerid, -1, "Use: /givescore [id] [score]");
up = up + soc;
SendClientMessage(playerid, -1, "You have gave a few scores to someone!");
SendClientMessage(playerid, -1, "You have recive some scores!");
return 1;
}
#include <zcmd>
COMMAND:givescore(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You aren't authorized to use this command");
new target,score;
if(sscanf(params, "ii", target,score)) return SendClientMessage(playerid, -1, "Usage: /givescore [PlayerID][Score]");
SetPlayerScore(playerid, GetPlayerScore(playerid)+score);
SendClientMessage(target, -1, "An admin gave you score");
return 1;
}
COMMAND:setscore(playerid,params[])
{
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, -1, "You aren't authorized to use this command");
new target,score;
if(sscanf(params, "ii", target,score)) return SendClientMessage(playerid, -1, "Usage: /setscore [PlayerID][Score]");
SetPlayerScore(playerid, score);
SendClientMessage(target, -1, "An admin set you score");
return 1;
}
CMD:givescore(playerid, params[])
{
static ID, AMOUNT;
if(sscanf(params, "ui", ID, AMOUNT)) return SendClientMessage(playerid, -1, "Usage: /givescore [playerid] [score amount]");
SetPlayerScore(ID, GetPlayerScore(ID)+AMOUNT);
static string[100], PIDNAME[MAX_PLAYER_NAME], PNAME[MAX_PLAYER_NAME];
GetPlayerName(ID, PIDNAME, MAX_PLAYER_NAME);
format(string, sizeof(string), "%s gave you %i amount of scores.", PIDNAME, AMOUNT);
SendClientMessage(ID, -1, string);
GetPlayerName(playerid, PNAME, MAX_PLAYER_NAME);
format(string, sizeof(string), "You gave %i scores to %s", AMOUNT, PNAME);
SendClientMessage(playerid, -1, string);
return 1;
}