Buggy commands
#1

Hello guys!

i have some commands that spams my chat field and i dont know what to do.I litteraly tried EVERYTHING that i know.
Ive been stuck 3 days trying to fix this.And i cant!

What is wrong with my commands?Ive seen a lot of tutorials or house systems that use this kind of structure ,but it seems that mine is not working.WHY?

Please help.

pawn Код:
CMD:npirkti(playerid,params[])
{
    for(new h; h < MAX_HOUSES; h++)
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        if(IsPlayerInRangeOfPoint(playerid, 5, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY] , HouseInfo[h][hEnterZ]))
        {
            if(!strcmp(HouseInfo[h][hOwnerName], pName, false )) return SendClientMessage(playerid, COL_RED, "Tu jau turi namus!"); //You already have a house
            if(HouseInfo[h][hOwned] == 1) return SendClientMessage(playerid, COL_RED, "Sis namas jau nupirktas!Jei jis nuomuojamas gali ji nuomuoti.");  //This house is already brought
            if(GetPlayerMoney(playerid) < HouseInfo[h][hPrice]) return SendClientMessage(playerid, COL_RED, "Jums neuztenka pinigu ipirkti siam namui!"); //You dont have enough money
            strmid(HouseInfo[h][hOwnerName], pName, 0, strlen(pName),MAX_PLAYER_NAME);
            HouseInfo[h][hOwned] = 1;
            GivePlayerMoney(playerid,-HouseInfo[h][hPrice]);
            SendClientMessage(playerid, COL_RED,"Sveikiname, nusipirkote nama! Visas komandas rasite /namai.");
            HouseInfo[h][hIsRented] = 0;
            new labelstring[500];
            DestroyDynamic3DTextLabel(HouseInfo[h][hLabel]);
            DestroyDynamicMapIcon(HouseInfo[h][hIcon]);
            DestroyDynamicPickup(HouseInfo[h][hPickup]);

            format(labelstring, sizeof(labelstring),""TCCYAN"Savininkas: "TCRED"%s\n"TCCYAN"Nuoma: "TCRED"%s\n"TCCYAN"Nuomos kaina: "TCRED"%d\n"TCCYAN"Adresas: "TCRED"%s", HouseInfo[h][hOwnerName],HouseInfo[h][hRenter],HouseInfo[h][hRentPrice],HouseInfo[h][hAddress]);
            HouseInfo[h][hLabel] = CreateDynamic3DTextLabel(labelstring, COL_GREEN, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ], 20);
            HouseInfo[h][hPickup] = CreateDynamicPickup(1272, 1, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]);
            HouseInfo[h][hIcon] = CreateDynamicMapIcon(HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ], 32, 0,0);
            SaveHouseData(h);
            return 1;
        }
        else SendClientMessage(playerid, COL_RED, "Jus nesate prie parduodamo namo!"); //You are not near the house
    }
    return 1;
}


CMD:nparduoti(playerid,params[])
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, sizeof(pName));
    for(new h;h < MAX_HOUSES;h++)
    {
        if(IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]))
        {
            if(!strcmp(HouseInfo[h][hOwnerName], pName, false )) return SendClientMessage(playerid, COL_RED, "Tu neturi namo , kuri galetum parduot!"); //You dont have a house to sell
            if(HouseInfo[h][hGIsOccupied] != 0)
            {
                LinkVehicleToInterior(HouseInfo[h][hGIsOccupied], 0);
                SetVehicleVirtualWorld(HouseInfo[h][hGIsOccupied], 0);
                SetVehiclePos(HouseInfo[h][hGIsOccupied], HouseInfo[h][hGEnterX], HouseInfo[h][hGEnterX], HouseInfo[h][hGEnterX]);
                DestroyDynamic3DTextLabel(HouseInfo[h][hGLabel]);
                SetVehicleZAngle(HouseInfo[h][hGIsOccupied], HouseInfo[h][hGAngle]);
            }
            GivePlayerMoney(playerid,HouseInfo[h][hPrice]+HouseInfo[h][hMoney]);
            GivePlayerWeapon(playerid, HouseInfo[h][hGun1], HouseInfo[h][hAmmo1]);
            GivePlayerWeapon(playerid, HouseInfo[h][hGun2], HouseInfo[h][hAmmo2]);
            strmid(HouseInfo[h][hOwnerName], "Parduodamas!", 0, strlen("Parduodamas!"), 20);
            HouseInfo[h][hOwned] = 0;
            HouseInfo[h][hLocked] = 1;
            HouseInfo[h][hRentPrice] = 0;
            strmid(HouseInfo[h][hRenter],"Nera",0,strlen("Nera"),6);
            HouseInfo[h][hIsRented] = 0;
            HouseInfo[h][hGun1] = 0;
            HouseInfo[h][hGun2] = 0;
            HouseInfo[h][hAmmo1] = 0;
            HouseInfo[h][hAmmo2] = 0;
            HouseInfo[h][hhasAGarage] = 0;
            HouseInfo[h][hGIsOccupied] = 0;
            HouseInfo[h][hGIsLocked] = 1;

            DestroyDynamicPickup(HouseInfo[h][hPickup]);
            DestroyDynamic3DTextLabel(HouseInfo[h][hLabel]);
            DestroyDynamic3DTextLabel(HouseInfo[h][hGLabel]);
            DestroyDynamicMapIcon(HouseInfo[h][hIcon]);

            new labelstring[500];
            format(labelstring,sizeof(labelstring),""TCRED"Patalpa parduodama!\n"TCCYAN"Kaina: "TCRED"%d LT\n"TCCYAN"Adresas: "TCRED"%s\n"TCCYAN"Informacija: "TCRED"%s",HouseInfo[h][hPrice],HouseInfo[h][hAddress],HouseInfo[h][hDescription]);
            HouseInfo[h][hLabel] = CreateDynamic3DTextLabel(labelstring, COL_GREEN, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ], 20);
            HouseInfo[h][hPickup] = CreateDynamicPickup(1273, 1, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]);
            HouseInfo[h][hIcon] = CreateDynamicMapIcon(HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ], 31, 0,0);
        }
        else SendClientMessage(playerid, COL_RED, "Turi buti prie namo duru!"); //You are not near the house door
    }
    return 1;
}

CMD:namai(playerid,params[])
{
    for(new h;h < MAX_HOUSES; h++)
    {
        new pName[MAX_PLAYER_NAME];
        GetPlayerName(playerid, pName, sizeof(pName));
        if((IsPlayerInRangeOfPoint(playerid, 3, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY], HouseInfo[h][hEnterZ]) || IsPlayerInRangeOfPoint(playerid, 20, HouseInfo[h][hExitX], HouseInfo[h][hExitY], HouseInfo[h][hExitZ])))
        {
            if(strcmp(HouseInfo[h][hOwnerName], pName, false) == 0)
            {
                ShowPlayerDialog(playerid, DIALOG_HOUSE_COMMANDS, DIALOG_STYLE_LIST, "Namu komandos", "Namu spyna\nSusimoketi Mokescius\nNuoma\nNuomos kaina\nIsmesti nuomininka\nIsspirti visus", "Gerai", "Iseiti");
            }
            else if(strcmp(HouseInfo[h][hRenter], pName, false) == 0)
            {
                ShowPlayerDialog(playerid, DIALOG_HOUSE_RENTER_COMMANDS, DIALOG_STYLE_LIST, "Namu komandos", "Namu spyna\nIsspirti visus", "Gerai", "Iseiti");
            }
        }
        else SendClientMessage(playerid, COL_RED, "Tu ne savo namuose arba ne prie ju!"); // You are not near the house
    }
    return 1;
}
Reply
#2

Bump
Reply
#3

how about trying here: http://forum.sa-mp.com/forumdisplay.php?f=33

I think nobody understand what are these commands talking about! so you should paste your problem there, maybe you'll find a help faster.
Reply
#4

The mistake is that you send message that the player is not in range of that house without checking if the player is not in range of ANY house before doing that. Because the player is not near the first house, that doesn't mean that they're not close to another one.

pawn Код:
new bool: near_house;
for(new h; h < MAX_HOUSES; h++)
{
    if(IsPlayerInRangeOfPoint(playerid, 5, HouseInfo[h][hEnterX], HouseInfo[h][hEnterY] , HouseInfo[h][hEnterZ]))
    {
        // code..
        near_house = true;
        break;
    }
}
if (!near_house) SendClientMessage(playerid, COL_RED, "Jus nesate prie parduodamo namo!"); //You are not near the house
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)