Different parameters in one command
#6

Quote:
Originally Posted by SilverKiller
View Post
Show us your code.
pawn Code:
COMMAND:give(playerid, params[])
{
    new string[128], target, amount;
    if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "SERVER: You need to login first before using any command.");
    if(sscanf(params, " s[32]u", params, target, amount))
    {
        SCM(playerid, GREY, "[Parameters]: /give [option] [playerid]");
        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))
            {
                new playergun;
                new playerammo;
                playergun = GetPlayerWeapon(playerid);
                playerammo = GetPlayerAmmo(playerid);
                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);
                GiveZaiatWeapon(target, playergun, playerammo);
                RemoveZaiatWeapon(playerid, playergun);
                return 1;
            }
            else
            {
                SendClientMessage(playerid, COLOR_GREY, "SERVER: You are too far away from that player.");
                return 1;
            }
        }
    }
    if(strcmp(params, "weed", true))
    {
        if(IsPlayerLoggedIn(playerid))
        {
            SCM(playerid, GREY, "[Parameters]: /give weed [playerid] [amount]");
            return 1;
        }
        if(PlayerInfo[playerid][pWeed] < amount) return SendClientMessage(playerid, COLOR_GREY, "SERVER: You don't have that much weed.");
        PlayerInfo[playerid][pWeed] -= amount;
        PlayerInfo[target][pWeed] += amount;
        format(string, sizeof(string), "NOTE: %s has given you a %d grams of weed.", RPN(playerid), amount);
        SCM(target, COLOR_LIGHTBLUE, string);
        format(string, sizeof(string), "NOTE: You have given %s, %d grams of weed.", RPN(target), amount);
        SCM(playerid, COLOR_LIGHTBLUE, 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);
    }
    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: 2 Guest(s)