26.09.2012, 16:31
How can i script a /giverank Command? So that i can give Players a Rank for whatever Reason.
#include <a_samp>
#include <zcmd>
#include <sscanf2>
COMMAND:givescore(playerid, params[]){
new target, score; // Defining the target and the score you want to give
if(sscanf(params, "ud", target, params)){ // Checks if you typed everything in the right order. ( Target first and the amount of score you wish to give)
SendClientMessage(playerid, 0xFFFFFFFF, "/givescore [target] [score]"); // Sends this message if you didn't typ it in the right order.
return 1; // returns so the command doesen't execute when you type in the wrong order.
}
SetPlayerScore(target, score); // Sets the target to the selected score.
return 1;
}
CMD:giverank(playerid, params[])
{
if (PlayerInfo[playerid][pLeader] >= 1)
{
new string[128], giveplayerid, rank;
if(sscanf(params, "ud", giveplayerid, rank)) return SendClientMessageEx(playerid, COLOR_WHITE, "USAGE: /giverank [playerid] [Rank (1-6)]");
if(rank > 6 || rank < 0) { SendClientMessageEx(playerid, COLOR_GREY, " Don't go below number 0, or above number 6!"); return 1; }
if(IsPlayerConnected(giveplayerid))
{
if(PlayerInfo[playerid][pLeader] != PlayerInfo[giveplayerid][pMember])
{
SendClientMessageEx(playerid, COLOR_GRAD1, " That person is not in your faction!");
return 1;
}
if(rank > PlayerInfo[giveplayerid][pRank])
{
format(string, sizeof(string), " You have been promoted to a higher rank by %s.", GetPlayerNameEx(playerid));
}
if(rank < PlayerInfo[giveplayerid][pRank])
{
format(string, sizeof(string), " You have been demoted to a lower rank by %s.", GetPlayerNameEx(playerid));
}
PlayerInfo[giveplayerid][pRank] = rank;
SendClientMessageEx(giveplayerid, COLOR_LIGHTBLUE, string);
format(string, sizeof(string), " You have given %s rank %d.", GetPlayerNameEx(giveplayerid),rank);
SendClientMessageEx(playerid, COLOR_LIGHTBLUE, string);
}
}
else
{
SendClientMessageEx(playerid, COLOR_GRAD1, "You are not authorized to use that command (leaders only)!");
}
return 1;
}
Put this on top of your script
pawn Код:
pawn Код:
|
Put this on top of your script
pawn Код:
pawn Код:
|
SetPlayerScore(target, score);
SetPlayerScore(playerid, GetPlayerScore(playerid) + score);