[A little of help? :D] Property System - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [A little of help? :D] Property System (
/showthread.php?tid=280691)
[A little of help? :D] Property System -
leaNN! - 02.09.2011
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!
Re: [A little of help? :D] Property System -
leong124 - 02.09.2011
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
between lines and see which part of your code crashes.