Putgun in House
#1

I want to put my gun in my house but whenever I write the command nothing happens.

pawn Код:
else if(!strcmp(command, "putgun", true))
    {
        new hworld = GetPlayerVirtualWorld(playerid);
        new house = PlayerInfo[playerid][HouseID];
       
        for(new h = 1; h < sizeof(HouseInfo); h++)
        {
            if(hworld == HouseInfo[h][hInsideWorld])
            {
                if(house == HouseInfo[h][hInsideWorld])
                {
                    new
                    string[128], gunname[100], slot, playergun, playerammo;
                    playergun = GetPlayerWeapon(playerid);
                    playerammo = GetPlayerAmmo(playerid);

                    if(playergun < 1) return SCM(playerid, COLOR_LIGHTRED,"[Error]: You do not have a weapon.");
                    if(playerammo < 1) return SCM(playerid, COLOR_LIGHTRED,"[Error]: You do not have any ammo.");
                   
                    if(sscanf(params,"d", slot)) return SCM(playerid, COLOR_GREY,"[Usage]: /house putgun [slot].");
                    if(slot == 1)
                    {
                        if(HouseInfo[h][hWeapon1] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                        HouseInfo[h][hWeapon1] = playergun;
                        HouseInfo[h][hAmmo1] += playerammo;
                        RemovePlayerWeapon(playerid, playergun);
                        GetWeaponName(playergun, gunname, sizeof(gunname));
                        format(string, sizeof(string), "You have put your %s in slot 1.", gunname);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                    }
                    else if(slot == 2)
                    {
                        if(HouseInfo[h][hWeapon2] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                        HouseInfo[h][hWeapon2] = playergun;
                        HouseInfo[h][hAmmo2] += playerammo;
                        RemovePlayerWeapon(playerid, playergun);
                        GetWeaponName(playergun, gunname, sizeof(gunname));
                        format(string, sizeof(string), "You have put your %s in slot 2.", gunname);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                    }
                    else if(slot == 3)
                    {
                        if(HouseInfo[h][hWeapon3] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                        HouseInfo[h][hWeapon3] = playergun;
                        HouseInfo[h][hAmmo3] += playerammo;
                        RemovePlayerWeapon(playerid, playergun);
                        GetWeaponName(playergun, gunname, sizeof(gunname));
                        format(string, sizeof(string), "You have put your %s in slot 3.", gunname);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                    }
                    else if(slot == 4)
                    {
                        if(HouseInfo[h][hWeapon4] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                        HouseInfo[h][hWeapon4] = playergun;
                        HouseInfo[h][hAmmo4] += playerammo;
                        RemovePlayerWeapon(playerid, playergun);
                        GetWeaponName(playergun, gunname, sizeof(gunname));
                        format(string, sizeof(string), "You have put your %s in slot 4.", gunname);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                    }
                    return 1;
                }
            }
        }
    }
Reply
#2

Try This my brother

PHP код:
else if(!strcmp(cmdtext"/putgun"true))
    {
        new 
hworld GetPlayerVirtualWorld(playerid);
        new 
house PlayerInfo[playerid][HouseID];
       
        for(new 
1sizeof(HouseInfo); h++)
        {
            if(
hworld == HouseInfo[h][hInsideWorld])
            {
                if(
house == HouseInfo[h][hInsideWorld])
                {
                    new
                    
string[128], gunname[100], slotplayergunplayerammo;
                    
playergun GetPlayerWeapon(playerid);
                    
playerammo GetPlayerAmmo(playerid);
                    if(
playergun 1) return SCM(playeridCOLOR_LIGHTRED,"[Error]: You do not have a weapon.");
                    if(
playerammo 1) return SCM(playeridCOLOR_LIGHTRED,"[Error]: You do not have any ammo.");
                   
                    if(
sscanf(params,"d"slot)) return SCM(playeridCOLOR_GREY,"[Usage]: /house putgun [slot].");
                    if(
slot == 1)
                    {
                        if(
HouseInfo[h][hWeapon1] != 0) return SCM(playeridCOLOR_LIGHTRED"There is already a weapon in this slot.");
                        
HouseInfo[h][hWeapon1] = playergun;
                        
HouseInfo[h][hAmmo1] += playerammo;
                        
RemovePlayerWeapon(playeridplayergun);
                        
GetWeaponName(playergungunnamesizeof(gunname));
                        
format(stringsizeof(string), "You have put your %s in slot 1."gunname);
                        
SendClientMessage(playeridCOLOR_WHITEstring);
                        
PlayerActionMessage(playerid,20.0"places a weapon in the house vault.");
                    }
                    else if(
slot == 2)
                    {
                        if(
HouseInfo[h][hWeapon2] != 0) return SCM(playeridCOLOR_LIGHTRED"There is already a weapon in this slot.");
                        
HouseInfo[h][hWeapon2] = playergun;
                        
HouseInfo[h][hAmmo2] += playerammo;
                        
RemovePlayerWeapon(playeridplayergun);
                        
GetWeaponName(playergungunnamesizeof(gunname));
                        
format(stringsizeof(string), "You have put your %s in slot 2."gunname);
                        
SendClientMessage(playeridCOLOR_WHITEstring);
                        
PlayerActionMessage(playerid,20.0"places a weapon in the house vault.");
                    }
                    else if(
slot == 3)
                    {
                        if(
HouseInfo[h][hWeapon3] != 0) return SCM(playeridCOLOR_LIGHTRED"There is already a weapon in this slot.");
                        
HouseInfo[h][hWeapon3] = playergun;
                        
HouseInfo[h][hAmmo3] += playerammo;
                        
RemovePlayerWeapon(playeridplayergun);
                        
GetWeaponName(playergungunnamesizeof(gunname));
                        
format(stringsizeof(string), "You have put your %s in slot 3."gunname);
                        
SendClientMessage(playeridCOLOR_WHITEstring);
                        
PlayerActionMessage(playerid,20.0"places a weapon in the house vault.");
                    }
                    else if(
slot == 4)
                    {
                        if(
HouseInfo[h][hWeapon4] != 0) return SCM(playeridCOLOR_LIGHTRED"There is already a weapon in this slot.");
                        
HouseInfo[h][hWeapon4] = playergun;
                        
HouseInfo[h][hAmmo4] += playerammo;
                        
RemovePlayerWeapon(playeridplayergun);
                        
GetWeaponName(playergungunnamesizeof(gunname));
                        
format(stringsizeof(string), "You have put your %s in slot 4."gunname);
                        
SendClientMessage(playeridCOLOR_WHITEstring);
                        
PlayerActionMessage(playerid,20.0"places a weapon in the house vault.");
                    }
                    return 
1;
                }
            }
        }
    } 
Reply
#3

Quote:
Originally Posted by MCZOFT
Посмотреть сообщение
Try This my brother

pawn Код:
else if(!strcmp(cmdtext, "/putgun", true))
    {
        new hworld = GetPlayerVirtualWorld(playerid);
        new house = PlayerInfo[playerid][HouseID];
       
        for(new h = 1; h < sizeof(HouseInfo); h++)
        {
            if(hworld == HouseInfo[h][hInsideWorld])
            {
                if(house == HouseInfo[h][hInsideWorld])
                {
                    new
                    string[128], gunname[100], slot, playergun, playerammo;
                    playergun = GetPlayerWeapon(playerid);
                    playerammo = GetPlayerAmmo(playerid);

                    if(playergun < 1) return SCM(playerid, COLOR_LIGHTRED,"[Error]: You do not have a weapon.");
                    if(playerammo < 1) return SCM(playerid, COLOR_LIGHTRED,"[Error]: You do not have any ammo.");
                   
                    if(sscanf(params,"d", slot)) return SCM(playerid, COLOR_GREY,"[Usage]: /house putgun [slot].");
                    if(slot == 1)
                    {
                        if(HouseInfo[h][hWeapon1] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                        HouseInfo[h][hWeapon1] = playergun;
                        HouseInfo[h][hAmmo1] += playerammo;
                        RemovePlayerWeapon(playerid, playergun);
                        GetWeaponName(playergun, gunname, sizeof(gunname));
                        format(string, sizeof(string), "You have put your %s in slot 1.", gunname);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                    }
                    else if(slot == 2)
                    {
                        if(HouseInfo[h][hWeapon2] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                        HouseInfo[h][hWeapon2] = playergun;
                        HouseInfo[h][hAmmo2] += playerammo;
                        RemovePlayerWeapon(playerid, playergun);
                        GetWeaponName(playergun, gunname, sizeof(gunname));
                        format(string, sizeof(string), "You have put your %s in slot 2.", gunname);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                    }
                    else if(slot == 3)
                    {
                        if(HouseInfo[h][hWeapon3] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                        HouseInfo[h][hWeapon3] = playergun;
                        HouseInfo[h][hAmmo3] += playerammo;
                        RemovePlayerWeapon(playerid, playergun);
                        GetWeaponName(playergun, gunname, sizeof(gunname));
                        format(string, sizeof(string), "You have put your %s in slot 3.", gunname);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                    }
                    else if(slot == 4)
                    {
                        if(HouseInfo[h][hWeapon4] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                        HouseInfo[h][hWeapon4] = playergun;
                        HouseInfo[h][hAmmo4] += playerammo;
                        RemovePlayerWeapon(playerid, playergun);
                        GetWeaponName(playergun, gunname, sizeof(gunname));
                        format(string, sizeof(string), "You have put your %s in slot 4.", gunname);
                        SendClientMessage(playerid, COLOR_WHITE, string);
                        PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                    }
                    return 1;
                }
            }
        }
    }
Well /putgun won't work because the actual command is /house putgun [slot]. But yeah, still not working.
I suspect the problem lays in this line:
pawn Код:
if(sscanf(params,"d", slot)) return SCM(playerid, COLOR_GREY,"[Usage]: /house putgun [slot].");
Reply
#4

Try TO change it to putgun directly without the Ussage and test to see if it will work
Reply
#5

Yeah. That works perfectly! But I would like it like /house putgun not /houseputgun.
Reply
#6

Do you use zCMD? If so, you can try this instead of cmdtext. Ironically I used cmdtext too but it didn't work, but funnily enough using "params" worked. >.>

pawn Код:
CMD:cmd(playerid, params[])
{
    if(isnull(params))
    {
        SendClientMessage(playerid, -1, "USAGE: /cmd <option>");
        SendClientMessage(playerid, -1, "option1, option2");
    }
    if(!strcmp(params, "option1", true))
    {
        // shit
    }
    if(!strcmp(params, "option2", true))
    {
        // shit
    }
    return 1;
}
Reply
#7

heree
pawn Код:
if (strcmp(cmd, "/house", true) == 0)
    {
        new hworld = GetPlayerVirtualWorld(playerid);
        new house = PlayerInfo[playerid][HouseID];
        for(new h = 1; h < sizeof(HouseInfo); h++)
        {
            if(hworld == HouseInfo[h][hInsideWorld])
            {
                if(house == HouseInfo[h][hInsideWorld])
                {
                    new
                    string[128], gunname[100], slot, playergun, playerammo;
                    playergun = GetPlayerWeapon(playerid);
                    playerammo = GetPlayerAmmo(playerid);

                    if(playergun < 1) return SCM(playerid, COLOR_LIGHTRED,"[Error]: You do not have a weapon.");
                    if(playerammo < 1) return SCM(playerid, COLOR_LIGHTRED,"[Error]: You do not have any ammo.");

                    if(sscanf(params, "s[32]d", params, slot))
                    {
                        SendClientMessage(playerid, -1, "USAGE: /house putgun [slot]");
                        return 1;
                    }
                    else if(!strcmp(params, "putgun", true))
                    {
                        if(slot == 1)
                        {
                            if(HouseInfo[h][hWeapon1] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                            HouseInfo[h][hWeapon1] = playergun;
                            HouseInfo[h][hAmmo1] += playerammo;
                            RemovePlayerWeapon(playerid, playergun);
                            GetWeaponName(playergun, gunname, sizeof(gunname));
                            format(string, sizeof(string), "You have put your %s in slot 1.", gunname);
                            SendClientMessage(playerid, COLOR_WHITE, string);
                            PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                        }
                        else if(slot == 2)
                        {
                            if(HouseInfo[h][hWeapon2] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                            HouseInfo[h][hWeapon2] = playergun;
                            HouseInfo[h][hAmmo2] += playerammo;
                            RemovePlayerWeapon(playerid, playergun);
                            GetWeaponName(playergun, gunname, sizeof(gunname));
                            format(string, sizeof(string), "You have put your %s in slot 2.", gunname);
                            SendClientMessage(playerid, COLOR_WHITE, string);
                            PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                        }
                        else if(slot == 3)
                        {
                            if(HouseInfo[h][hWeapon3] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                            HouseInfo[h][hWeapon3] = playergun;
                            HouseInfo[h][hAmmo3] += playerammo;
                            RemovePlayerWeapon(playerid, playergun);
                            GetWeaponName(playergun, gunname, sizeof(gunname));
                            format(string, sizeof(string), "You have put your %s in slot 3.", gunname);
                            SendClientMessage(playerid, COLOR_WHITE, string);
                            PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                        }
                        else if(slot == 4)
                        {
                            if(HouseInfo[h][hWeapon4] != 0) return SCM(playerid, COLOR_LIGHTRED, "There is already a weapon in this slot.");
                            HouseInfo[h][hWeapon4] = playergun;
                            HouseInfo[h][hAmmo4] += playerammo;
                            RemovePlayerWeapon(playerid, playergun);
                            GetWeaponName(playergun, gunname, sizeof(gunname));
                            format(string, sizeof(string), "You have put your %s in slot 4.", gunname);
                            SendClientMessage(playerid, COLOR_WHITE, string);
                            PlayerActionMessage(playerid,20.0, "places a weapon in the house vault.");
                        }
                    }
                    return 1;
                }
            }
        }
    }
Reply
#8

Aww, screw it. I'll just use /putgun and /takegun.
Reply
#9

Have you tried what i gave you?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)