[HELP]/Givedrug
#1

Instead of using /givedrug (giving a person) I want to /givedrug [playerid] [ammount] [price] (giving a person drugs as that player buy it) basically like a /selldrug cmd. How do I do it here's the code below.

Код:
CMD:givedrug(playerid, params[])
{
    new
	give[24], id, amount, string[128];

    if(sscanf(params, "is[24]d", id, give, amount)) return SendClientMessage(playerid, COLOR_GREY, "[SERVER] /givedrug [playerid] (beer, cigarette, lsd, marijuana, cocaine, meth, ecstasy, seeds, heroin, crack) [amount]");
    if(!strcmp(give, "lsd", true))
    {
   		new Float:x, Float:y, Float:z;
		GetPlayerPos(id, x, y, z);
    	if(!IsPlayerInRangeOfPoint(playerid, 7.0, x, y, z)) return SCM(playerid, COLOR_LIGHTRED, "You are not close to that player.");
	    if (id == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_LIGHTRED, "That player is not connected.");
	    if (amount > PlayerInfo[playerid][dLSD]) return SendClientMessage(playerid, COLOR_LIGHTRED, "You do not have that much LSD.");
	    if (playerid == id) return SendClientMessage(playerid, COLOR_LIGHTRED,"You can't give yourself LSD.");

	    PlayerInfo[id][dLSD] += amount;
	    PlayerInfo[playerid][dLSD] -= amount;
	    format(string, sizeof(string), "You have received %dg LSD from %s.",amount, GetName(playerid));
	    SendClientMessage(id, COLOR_WHITE, string);
	    format(string, sizeof(string), "%s gives a baggie to %s.", GetName(playerid), GetName(id));
	    ProxDetector(20.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
     	new string2[128];
	    format(string2, sizeof(string2), "* %s gives a baggie to %s.", GetName(playerid), GetName(id));
	    SetPlayerChatBubble(playerid, string2, COLOR_PURPLE, 100.0, 10000);
	    format(string, sizeof(string), "You have given %s %dg of LSD.",GetName(id),amount);
	    SendClientMessage(playerid, COLOR_WHITE, string);
    }
Reply
#2

Try this one.

PHP код:
CMD:givedrug(playeridparams[])
{
    new
    
give[24], idamountstring[128];
    if(
sscanf(params"is[24]d"idgiveamount)) return SendClientMessage(playeridCOLOR_GREY"[SERVER] /givedrug [playerid] (beer, cigarette, lsd, marijuana, cocaine, meth, ecstasy, seeds, heroin, crack) [amount]");
    if(!
strcmp(give"lsd"true))
    {
           new 
Float:xFloat:yFloat:z;
        
GetPlayerPos(idxyz);
        
GivePlayerMoney(ivalue);
        if(!
IsPlayerInRangeOfPoint(playerid7.0xyz)) return SCM(playeridCOLOR_LIGHTRED"You are not close to that player.");
        if (
id == INVALID_PLAYER_ID) return SendClientMessage(playeridCOLOR_LIGHTRED"That player is not connected.");
        if (
amount PlayerInfo[playerid][dLSD]) return SendClientMessage(playeridCOLOR_LIGHTRED"You do not have that much LSD.");
        if (
playerid == id) return SendClientMessage(playeridCOLOR_LIGHTRED,"You can't give yourself LSD.");
        
PlayerInfo[id][dLSD] += amount;
        
PlayerInfo[playerid][dLSD] -= amount;
        
format(stringsizeof(string), "You have received %dg LSD from %s.",amountGetName(playerid));
        
SendClientMessage(idCOLOR_WHITEstring);
        
format(stringsizeof(string), "%s gives a baggie to %s."GetName(playerid), GetName(id));
        
ProxDetector(20.0playeridstringCOLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
         new 
string2[128];
        
format(string2sizeof(string2), "* %s gives a baggie to %s."GetName(playerid), GetName(id));
        
SetPlayerChatBubble(playeridstring2COLOR_PURPLE100.010000);
        
format(stringsizeof(string), "You have given %s %dg of LSD.",GetName(id),amount);
        
SendClientMessage(playeridCOLOR_WHITEstring);
    } 
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)