/givescore
#1

How can i script a Command to give a Player Score, and that only Admins can make it?
Reply
#2

Use this or convert it into CMD:


pawn Код:
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);
}
Reply
#3

PHP код:
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;

If you meant /setscore;

PHP код:
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;

@Eminem 2ka9 - Why copy from other scripts?..
Reply
#4

PHP код:
COMMAND:setscore(playerid,params[])
{
    if(
PlayerInfo[playerid][AdminLevel] >= LEVEL_setscore)
    {
        new 
playeramount;
        if(
sscanf(params"rd"playeramount))
        {
            
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(playeramount);
        }
         else
         {
             
SendClientMessage(playerid,RED,"ERROR: Player is not connected");
        }
    }
    else
    {
        
SendClientMessage(playeridRED"Not enought permission");
    }
    return 
1;

or..
PHP код:
CMD:setscore(playerid,params[]) {
    if(
PlayerInfo[playerid][Level] >= 5) {
        new 
tmp[256], tmp2[256], Indextmp strtok(params,Index), tmp2 strtok(params,Index);
        if(
isnull(tmp) || isnull(tmp2) || !IsNumeric(tmp2)) return SendClientMessage(playeridred"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(stringsizeof(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(player1score);
        } 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");

Reply
#5

Simply code

pawn Код:
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;
}
Reply
#6

SetPlayerScore(player1, GetPlayerScore(player1) +score);
Reply
#7

First of all download zcmd : https://sampforum.blast.hk/showthread.php?tid=91354

include it at top of the script
PHP код:
#include <zcmd> 
Then use this code to give:
PHP код:
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(playeridGetPlayerScore(playerid)+score);
    
SendClientMessage(target, -1"An admin gave you score");
    return 
1;

To set score, use this:
PHP код:
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(playeridscore);
    
SendClientMessage(target, -1"An admin set you score");
    return 
1;

Reply
#8

VEry Simple

PHP код:
CMD:givescore(playeridparams[])
{
 static 
IDAMOUNT;
 if(
sscanf(params"ui"IDAMOUNT)) return SendClientMessage(playerid, -1"Usage: /givescore [playerid] [score amount]");
 
SetPlayerScore(IDGetPlayerScore(ID)+AMOUNT);
 static 
string[100], PIDNAME[MAX_PLAYER_NAME], PNAME[MAX_PLAYER_NAME];
 
GetPlayerName(IDPIDNAMEMAX_PLAYER_NAME);
 
format(stringsizeof(string), "%s gave you %i amount of scores."PIDNAMEAMOUNT);
 
SendClientMessage(ID, -1string);
 
GetPlayerName(playeridPNAMEMAX_PLAYER_NAME);
 
format(stringsizeof(string), "You gave %i scores to %s"AMOUNT,  PNAME);
 
SendClientMessage(playerid, -1string);
 return 
1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)