PDA

View Full Version : addcash


BloodGod
02/09/2011, 11:02 AM
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

doreto
02/09/2011, 11:13 AM
http://forum.sa-mp.com/search.php

Davz*|*Criss
02/09/2011, 11:20 AM
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?

Amel_PAtomAXx
02/09/2011, 11:25 AM
first define COLOR_GREEN , COLOR_GREY and COLOR_ORANGE


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;
}

Davz*|*Criss
02/09/2011, 11:31 AM
first define COLOR_GREEN , COLOR_GREY and COLOR_ORANGE


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.

#define COLOR_GREEN 0x00FF00FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_ORANGE 0xF88017FF

Amel_PAtomAXx
02/09/2011, 11:32 AM
Isnt that copied fastly from something? :)

Colour defines are here:

Put it on top.

#define COLOR_GREEN 0x00FF00FF
#define COLOR_GREY 0xAFAFAFAA
#define COLOR_ORANGE 0xF88017FF


its copy from my server , is that problem ??

BloodGod
02/09/2011, 11:32 AM
http://forum.sa-mp.com/search.php
I used search!

first define COLOR_GREEN , COLOR_GREY and COLOR_ORANGE


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)

Davz*|*Criss
02/09/2011, 11:42 AM
I have provided to by myself in ZCMD and DCMD.

Here you go:


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;
}

BloodGod
02/09/2011, 11:54 AM
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

Kingunit
02/09/2011, 12:27 PM
Try this:

//-----[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)

Davz*|*Criss
02/09/2011, 02:43 PM
Yeah define that ontop:


#define COLOR_WHITE 0xffffffff