addcash
#1

Hi
I want to make a command that you can add cash..
But how can you get the playerid from the other player from who you send to, and then give the other player the cash?

must be like /addcash [id] [cash]

so how can you get the id from the otherplayer and give it to the otherplayer?!

thnx
Reply
#2

http://forum.sa-mp.com/search.php
Reply
#3

What do you mean by Addcash?

You mean a regular player cmd that can send his money to other?

Or an adminstrator cmd like /setcash 1 5000000000000?
Reply
#4

first define COLOR_GREEN , COLOR_GREY and COLOR_ORANGE

pawn Код:
if(strcmp(cmd, "/setmoney", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "USAGE: /setmoney [playerid/PartOfName] [Ammount]");
                return 1;
            }
            new giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME],string[128],string2[128];
            new para1;
            new level;
            para1 = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            level = strval(tmp);
            if(IsPlayerAdmin(playerid)) // here put your admin system
            {
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        ResetPlayerMoney(para1);
                        GivePlayerMoney(para1,level);
                        format(string, sizeof(string), " Admin %s has set your money to %d .",sendername,level);
                        SendClientMessage(para1, COLOR_GREEN, string);
                        format(string2, sizeof(string2), "You have set %s's money to %d.", giveplayer,level);
                        SendClientMessage(playerid, COLOR_ORANGE, string2);

                    }
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GREY,"Player not Connected");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
            }
        }
        return 1;
    }
Reply
#5

Quote:
Originally Posted by Amel_PAtomAXx
Посмотреть сообщение
first define COLOR_GREEN , COLOR_GREY and COLOR_ORANGE

pawn Код:
if(strcmp(cmd, "/setmoney", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "USAGE: /setmoney [playerid/PartOfName] [Ammount]");
                return 1;
            }
            new giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME],string[128],string2[128];
            new para1;
            new level;
            para1 = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            level = strval(tmp);
            if(IsPlayerAdmin(playerid)) // here put your admin system
            {
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        ResetPlayerMoney(para1);
                        GivePlayerMoney(para1,level);
                        format(string, sizeof(string), " Admin %s has set your money to %d .",sendername,level);
                        SendClientMessage(para1, COLOR_GREEN, string);
                        format(string2, sizeof(string2), "You have set %s's money to %d.", giveplayer,level);
                        SendClientMessage(playerid, COLOR_ORANGE, string2);

                    }
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GREY,"Player not Connected");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
            }
        }
        return 1;
    }
Isnt that copied fastly from something?

Colour defines are here:

Put it on top.

pawn Код:
#define COLOR_GREEN 0x00FF00FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_ORANGE 0xF88017FF
Reply
#6

Quote:
Originally Posted by Davz*|*Criss
Посмотреть сообщение
Isnt that copied fastly from something?

Colour defines are here:

Put it on top.

pawn Код:
#define COLOR_GREEN 0x00FF00FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_ORANGE 0xF88017FF
its copy from my server , is that problem ??
Reply
#7

Quote:
Originally Posted by doreto
Посмотреть сообщение
I used search!

Quote:
Originally Posted by Amel_PAtomAXx
Посмотреть сообщение
first define COLOR_GREEN , COLOR_GREY and COLOR_ORANGE

pawn Код:
if(strcmp(cmd, "/setmoney", true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
            tmp = strtok(cmdtext, idx);
            if(!strlen(tmp))
            {
                SendClientMessage(playerid, COLOR_GREY, "USAGE: /setmoney [playerid/PartOfName] [Ammount]");
                return 1;
            }
            new giveplayer[MAX_PLAYER_NAME],sendername[MAX_PLAYER_NAME],string[128],string2[128];
            new para1;
            new level;
            para1 = ReturnUser(tmp);
            tmp = strtok(cmdtext, idx);
            level = strval(tmp);
            if(IsPlayerAdmin(playerid)) // here put your admin system
            {
                if(IsPlayerConnected(para1))
                {
                    if(para1 != INVALID_PLAYER_ID)
                    {
                        GetPlayerName(para1, giveplayer, sizeof(giveplayer));
                        GetPlayerName(playerid, sendername, sizeof(sendername));
                        ResetPlayerMoney(para1);
                        GivePlayerMoney(para1,level);
                        format(string, sizeof(string), " Admin %s has set your money to %d .",sendername,level);
                        SendClientMessage(para1, COLOR_GREEN, string);
                        format(string2, sizeof(string2), "You have set %s's money to %d.", giveplayer,level);
                        SendClientMessage(playerid, COLOR_ORANGE, string2);

                    }
                }
                else
                {
                    SendClientMessage(playerid,COLOR_GREY,"Player not Connected");
                }
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "You are not authorized to use that command!");
            }
        }
        return 1;
    }
Issn't it easier with DCMD? (Im using dcmd)
Reply
#8

I have provided to by myself in ZCMD and DCMD.

Here you go:

pawn Код:
CMD:setcash(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You are not authorized to use that command!");
    new str[105], TargetID, Ammount;
    if(sscanf(params, "ud", TargetID, Ammount)) {
        return SendClientMessage(playerid, 0xFFFFAAFF, "Usage: /SetCash (PlayerID/PartOfName) (Ammount)."); }
    else if(TargetID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFAAFF, "Player not connected.");

    new Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(TargetID, Name2, sizeof(Name2));
    format(str, sizeof(str), "Adminstrator: %s has set %'s cash ammount to", Name1, Name2, Ammount);
    SendClientMessageToAll(0xFFFFAAFF, str);
    GivePlayerMoney(TargetID, Ammount);
    return 1;
}

dcmd_setcash(playerid, params[])
{
    #pragma unused params
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF0000FF, "You are not authorized to use that command!");
    new str[105], TargetID, Ammount;
    if(sscanf(params, "ud", TargetID, Ammount)) {
        return SendClientMessage(playerid, 0xFFFFAAFF, "Usage: /SetCash (PlayerID/PartOfName) (Ammount)."); }
    else if(TargetID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xFFFFAAFF, "Player not connected.");

    new Name1[MAX_PLAYER_NAME], Name2[MAX_PLAYER_NAME];
    GetPlayerName(playerid, Name1, sizeof(Name1));
    GetPlayerName(TargetID, Name2, sizeof(Name2));
    format(str, sizeof(str), "Adminstrator: %s has set %'s cash ammount to", Name1, Name2, Ammount);
    SendClientMessageToAll(0xFFFFAAFF, str);
    GivePlayerMoney(TargetID, Ammount);
    return 1;
}
Reply
#9

Quote:
Originally Posted by Davz*|*Criss
Посмотреть сообщение
What do you mean by Addcash?

You mean a regular player cmd that can send his money to other?

Or an adminstrator cmd like /setcash 1 5000000000000?


I mean this:

A player haves 10000 cash
If a admin does /addcash [his ID] [30000]
that he get 40000 cash
Reply
#10

Try this:
pawn Код:
//-----[Addcash]-----
CMD:addcash(playerid, params[])
{
    {
        if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,COLOR_WHITE,".:: You are not authorized to use this command ::."); // Replace with your own Admin system.
        new targetid, money;
        if(sscanf(params, "ui", targetid,money)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /addcash [PlayerID] [Amount]");
        if(!IsPlayerConnected(targetid)) return SendClientMessage(playerid, COLOR_WHITE, "Player not connected!");
        else
        {
            new string[256];
            new pName[24];
            GetPlayerRame(playerid,pName,24);
            format(string,sizeof string,"Administrator %s gave you $%d.",pName, money);
            SendClientMessage(targetid, COLOR_WHITE, string);
            GivePlayerMoney(targetid, money);
        }
    }
    return 1;
}
You need to define also the color white (COLOR_WHITE)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)