[A little of help? :D] Property System
#1

Hi fellows:B.

Well, im using the FS wich include Bank, property, gang, but with some edits.

Mi problem is that when any user buys a property that already has an owner, server crashs.
Ex: If John owns Caligula's Casino and i buy Caligula's Casino, the server crash.

The /buy CMD:

pawn Код:
if(strcmp(cmd, "/comprar", true) == 0) {
        new property=999;

        if(IsPlayerInCheckpoint(playerid)) {
            switch (playerCheckpoint[playerid]) {
                case CP_ALAHAM:{
                    property = P_ALAHAM;
                }
                case CP_DIDERSACHS:{
                    property = P_DIDERSACHS;
                }
                case CP_BAR:{
                    property = P_BAR;
                }
                case CP_HAIRSTUD:{
                    property = P_HAIRSTUD;
                }
                case CP_ZIP:{
                    property = P_ZIP;
                }
                case CP_BINCO:{
                    property = P_BINCO;
                }
                case CP_TATOO:{
                    property = P_TATOO;
                }
                case CP_GOLF:{
                    property = P_GOLF;
                }
                case CP_WANG:{
                    property = P_WANG;
                }
                case CP_HOTEL:{
                    property = P_HOTEL;
                }
                case CP_OTTOS:{
                    property = P_OTTOS;
                }
                case CP_DRAGON:{
                    property = P_DRAGON;
                }
                case CP_CALIGULA:{
                    property = P_CALIGULA;
                }
                case CP_SEXSHOP:{
                    property = P_SEXSHOP;
                }
                case CP_CATHAY:{
                    property = P_CATHAY;
                }
                case CP_VERONA:{
                    property = P_VERONA;
                }
                case CP_ZERORC:{
                    property = P_ZERORC;
                }
                case CP_JIZZYS:{
                    property = P_JIZZYS;
                }
                case CP_PIRAMID:{
                    property = P_PIRAMID;
                }
            }

            if(property==999) {
                SendClientMessage(playerid, COLOR_YELLOW, "Necesitas estar en el checkpoint de la propiedad para comprarla!");
                return 1;
            }

//          property--;

            if(GetPlayerMoney(playerid) < propertyValues[property]) {
                SendClientMessage(playerid, COLOR_RED, "No tienes dinero suficiente para comprar esta propiedad.");
                return 1;
            }
            if(propertyOwner[property]==playerid) {
                SendClientMessage(playerid, COLOR_RED, "Eres dueсo de esta propiedad.");
                return 1;
            }

            if(propertyOwner[property] < 999)
            {
                GetPlayerName(playerid, giveplayer, sizeof(giveplayer));
                GivePlayerMoney(propertyOwner[property], propertyValues[property]);
                format (string, sizeof(string), "Tu propiedad, %s, fue comprada por %s (id: %d).", propertyNames[property], giveplayer, playerid);
                SendClientMessage(propertyOwner[property], COLOR_RED, string);
            }

            GivePlayerMoney(playerid, -propertyValues[property]);

            propertyOwner[property] = playerid;
            propiedad[playerid] = property;

            format(string, sizeof(string), "Compraste la propiedad %s!", propertyNames[property]);
            SendClientMessage(playerid, COLOR_GREEN, string);

        } else {
            SendClientMessage(playerid, COLOR_YELLOW, "Necesitas estar en el checkpoint de la propiedad para comprarla!");
            return 1;
        }


        return 1;
    }
(The command is in Spanish, im from Argentina and i traduced it :B.)
Well, anything else.

Sorry for my bad english, and thanks!
Reply
#2

What is the size of the array "propertyOwner"? Is that possible that the value of the variable "property" is larger than the size of the array "propertyOwner"?

Generally, try to put something like
pawn Код:
print("hi");
between lines and see which part of your code crashes.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)