YCMD:destroydealership(playerid, params[], help) {
new id;
if(!IsPlayerAdmin(playerid)) return 0;
else {
if(sscanf(params, "d", id)) return SendClientMessage(playerid, COLOR_NOTE, "[ ! ] SYNTAX: /DestroyDealership [DS-ID]");
else {
new query[128];
mysql_format(dbHandle, query, sizeof(query), "DELETE FROM `dealerships` WHERE `DsID` = %d", DS[id][DsID]);
mysql_tquery(dbHandle, query, "destroyDEALERSHIP", "dd", playerid, id);
}
}
return 1;
}
//Here I tried to check maybe if I used id instead of DS[id][DsIcon] would work.
forward delPICKUP(id);
public delPICKUP(id) {
DestroyPickup(id);
return 1;
}
forward updateDS();
public updateDS() {
mysql_tquery(dbHandle, "SELECT * FROM `dealerships`", "loadDEALERSHIPS");
return 1;
}
forward destroyDEALERSHIP(playerid, id);
public destroyDEALERSHIP(playerid, id) {
if(cache_affected_rows(dbHandle) > 0) {
if(id > 0 && id < cache_num_rows(dbHandle)) {
DestroyPickup(DS[id][DsIcon]);
printf("Successfully deleted dealership id %d --", id);
format(ZString, sizeof(ZString), "[ ! ] Successfully DELETED DealerShip ID:%d. (SQL-ROW-ID:%d)", id, DS[id][DsID]); //Thanks to 'rickisme' for helping me with this one.
SendClientMessage(playerid, COLOR_SUCCESS, ZString);
mysql_tquery(dbHandle, "SELECT * FROM `dealerships`", "loadDEALERSHIPS");
SetTimerEx("delPICKUP", 1000, false, "d", id);
SetTimer("updateDS", 2000, false);
} else return SendClientMessage(playerid, COLOR_ERROR, "[ ! ] Invalid DEALERSHIP ID.");
}
return 1;
}
That is usually caused by something crashing, often out-of-bounds array accesses. The crash detect plugin can detect many of these crashes (hence its name), but not all, so in other cases you may need to cover your code in print statements and see exactly which line the code stops on.
|