Different parameters in one command
#9

I'm not sure if this will work, but try it:

pawn Code:
COMMAND:giveweapon(playerid, params[])
{
    new target, weapon, amount;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: You need to login first before using any command.");
    if(sscanf(params, "udd", target, amount))
    {
        SCM(playerid, GREY, "[Parameters]: /give [option] [playerid] [amount]");
        SCM(playerid, COLOR_FADE1, "[Options]: weapon | weed");
        return 1;
    }
    if(!strcmp(params, "weapon", true))
    {
        if(target == playerid) return SCM(playerid, COLOR_GREY, "SERVER: You can't give it to yourself.");
        if(IsPlayerConnected(target))
        {
            if(IsPlayerNearPlayer(playerid, target, 1))
            {
                if(sscanf(params, "udd", target, amount)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /give weapon [playerid] [weapon] [amount]");
                new string[128];
                format(string, sizeof(string), "%s has given you a %s with %d ammo.", RPN(playerid), RWN(GetPlayerWeapon(playerid)), GetPlayerAmmo(playerid));
                SCM(target, COLOR_NEWBLUE, string);
                format(string, sizeof(string), "You have given %s a %s with %d ammo.", RPN(target), RWN(GetPlayerWeapon(playerid)), GetPlayerAmmo(playerid));
                SCM(playerid, COLOR_NEWBLUE, string);
                format(string, sizeof(string), "%s glances towards %s as he gives him/her something.", RPN(playerid), RPN(target));
                SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
                SetPlayerChatBubble(playerid, string, COLOR_PURPLE, 15.0, 5000);
                SetPlayerFacingPlayer(playerid, target);
                ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                ApplyAnimation(target,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
                GivePlayerWeapon(target, weapon, amount);
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "SERVER: You are too far away from that player.");
                return 1;
            }
        }
    }
    if(strcmp(params, "weed", true))
    {
        new wAmount;
        new tArget;
        if(IsPlayerLoggedIn(playerid))
        {
            SCM(playerid, GREY, "You are not logged in!");
            return 1;
        }
        new Str[128];
        else if(sscanf(params, "ud", tArget, wAmount)) return SendClientMessage(playerid, COLOR_GREY, "Usage: /give weed [playerid] [amount]");
        else if(PlayerInfo[playerid][pWeed] < wAmount) return SendClientMessage(playerid, COLOR_GREY, "SERVER: You don't have that much weed.");
        PlayerInfo[playerid][pWeed] -= wAmount;
        PlayerInfo[target][pWeed] += wAmount;
        format(Str, sizeof(Str), "NOTE: %s has given you a %d grams of weed.", RPN(playerid), wAmount);
        SCM(target, COLOR_LIGHTBLUE, Str);
        format(Str, sizeof(Str), "NOTE: You have given %s, %d grams of weed.", RPN(target), wAmount);
        SCM(playerid, COLOR_LIGHTBLUE, Str);
        format(Str, sizeof(Str), "%s glances towards %s as he gives him/her something.", RPN(playerid), RPN(tArget));
        SendNearbyMessage(playerid, 15, Str, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
        SetPlayerChatBubble(playerid, Str, COLOR_PURPLE, 15.0, 5000);
        SetPlayerFacingPlayer(playerid, tArget);
        ApplyAnimation(playerid,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
        ApplyAnimation(tArget,"DEALER", "DEALER_DEAL",4.0,0,0,0,0,0);
    }
    return 1;
}
Reply


Messages In This Thread
Different parameters in one command - by Sasoft - 20.06.2013, 12:27
Re: Different parameters in one command - by S0n1COwnsYou - 20.06.2013, 12:37
Re: Different parameters in one command - by Sasoft - 20.06.2013, 12:51
Re: Different parameters in one command - by S0n1COwnsYou - 20.06.2013, 12:58
Re: Different parameters in one command - by SilverKiller - 20.06.2013, 13:29
Re: Different parameters in one command - by Sasoft - 20.06.2013, 13:55
Re: Different parameters in one command - by Vince - 20.06.2013, 13:57
Re: Different parameters in one command - by Sasoft - 20.06.2013, 14:00
Re: Different parameters in one command - by SilverKiller - 20.06.2013, 14:12

Forum Jump:


Users browsing this thread: 4 Guest(s)