Pickup problem
#1

Hi guys I have a problem. I made an event system based on pickups and did it all right but it interferes with my other pickups at my rent car and at my dealership, how can I prevent that? I will give you the oplace, removeoplace and the public OnPlayerPickUpPickup
Commands:
Код:
CMD:oplace(playerid, params[]) {
	if(PlayerInfo[playerid][pLogged] == 0) return 1;
	if(PlayerInfo[playerid][pAdmin] == 0) return SCM(playerid, COLOR_RED, AdminOnly);
	new obj, money;
	SetPVarInt(playerid, "objmodel", obj);
	if(sscanf(params,"ii", obj, money)) return SCM(playerid, -1, "* (CmdBot) : Syntax : /oplace <obj> <money>");
	if(obj < 1 || obj > 20000) return SCM(playerid, COLOR_EROARE, "* Invalid object!");
	if(money < 1 || money > 10000000) return SCM(playerid, COLOR_EROARE, "* Invalid money.");
	new id = CountObjects(), Float:Pos[3], string[128];
	GetPlayerPos(playerid, Pos[0], Pos[1], Pos[2]);
	ObjectID[id] = CreatePickup(obj, 23, Pos[0] + 5, Pos[1], Pos[2]);
	ObjectMoney[id] = money;
	format(string, sizeof(string), "AdmCmd: %s has placed a new object, model %d, money %d. Acum sunt %d obiecte.", GetName(playerid), obj, money, id+1);
	SendAdminMessage(string);
	AddStaffLog(playerid, "a plasat un obiect, model %d money %d.", obj, money);
	return 1;
}

CMD:removeoplace(playerid, params[]) {
	if(PlayerInfo[playerid][pLogged] == 0) return 1;
	if(PlayerInfo[playerid][pAdmin] == 0) return SCM(playerid, COLOR_RED, AdminOnly);
	new string[128];
	for(new i = 0; i < MAX_OBJECTS; i++) {
		if(ObjectID[i] != 0) {
			DestroyObject(ObjectID[i]);
			ObjectID[i] = 0;
			ObjectMoney[i] = 0;
		}
	}
	format(string, sizeof(string), "AdmCmd: %s a sters %d obiecte.", GetName(playerid), CountObjects());
	SendAdminMessage(string);
	AddStaffLog(playerid, "a sters %d obiecte.", CountObjects());
	return 1;
}
My forward and public to count objects:
Код:
forward CountObjects();
public CountObjects() {
	new x;
	for(new i = 0; i < MAX_OBJECTS; i++) {
		if(ObjectID[i] != 0) x++;
	}
	return x;
}
OnPlayerPickUpPickup:
Код:
new string[128];
	for(new i = 0; i < MAX_OBJECTS; i++) {
		if(pickupid == ObjectID[i] && ObjectID[i] != -1) {
			if(PlayerInfo[playerid][pAdmin] < 6) return SCM(playerid, COLOR_EROARE, "* Adminii nu participa la eventuri!");
			new id = CountObjects();
			format(string, sizeof(string), "AdmBot: %s a gasit un obiect din event si a castigat $%d.", GetName(playerid), ObjectMoney[i]);
			SCMTOALL(COLOR_ANNOUNCE2, string);
			SendAdminMessage(string);
			AddPlayerLog(playerid, "a gasit un obiect si a castigat $%d.", ObjectMoney[i]);
			GivePlayerMoney(playerid, ObjectMoney[i]);
			if(id-1 > 1) format(string, sizeof(string), "AdmBot: In acest moment mai sunt %d obiecte.", id-1);
			else if(id-1 == 1) format(string, sizeof(string), "AdmBot: Mai este doar un obiect disponibil.");
			else if(id-1 == 0) format(string, sizeof(string), "AdmBot: Evenimentul a luat sfarsit, multumim pentru participare.");
			SCMTOALL(COLOR_ANNOUNCE2, string);
			SendAdminMessage(string);
			DestroyPickup(ObjectID[i]);
			ObjectID[i] = 0;
			ObjectMoney[i] = 0;
		}
	}
The pickups at my rentcar and dealership:
Код:
CreatePickup(1318, 1, 2162.3306,1407.3198,10.8203, -1);
	CreatePickup(1277, 1, 2016.9685,1916.4336,12.3424, -1);
Any help is appreciated, thanks.
Reply
#2

You didn't do it alright, as you haven't tracked the pickup...

new DealerPickup;

DealerPickup = CreatePickup(bla,de,bla)

if(pickupid==DealerPickup) You're at the dealership...


If you have multiple dealerships, you'll need to make an array, or make enums for the pickups, to give them a flag to state what business they are actually for.

Make an array.
Reply
#3

Solved. Thanks buddy.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)