Need idea for entrance
#1

Hello

Like we all know using button to entrance business is not lag free. SYstem have to chek every player/business coords and stuff. So i need better idea for that. Somebody has a god idea for me?

With this idea i should be able to entrance and exit businesses :P
Reply
#2

Put a door with a command /opendoor1 with a timer and this command work only for what player you want .
Reply
#3

a hashtable will solve your problem - let me assume some circumstances of your house system...
-each house/interior/shop, gets assigned an unique ID
-load/create houses (prefreably from a file/database for being able to reload them, no need to restart server for 1 change), including the spawn coordinates for the pickup at its outside entrance, and one for the exit pickup in the innerside.
-when creating enter/exit pickups, also write the unique houseID into an array, where the cell equals the pickupid, which got returned when creating the pickups.
-now, when a player touches a pickup (lets say pickups==1234), then the array cell PickupLinksToUniqueInteriorID[pickupid] == your desired house to enter.

this concept works for a lot of stuff, it outperforms any linear/binary search, but got some disadvantages, too, which are irrelevant in your case (like each house must have an unique ID assigned, or the IDs should be serialized, raising up from 0 or 1, to a maxuimum - hence the array size needs to be big enough to hold each single house).

lateron, when you are (if not already done so) about to change to the streamer plugin, you also can add some mapicons to the radar, and maybe 3dtextlabels, to let players know where to find a house to buy. since there are >2000 houses in SA, its a wise decision to switch right now.
Reply
#4

I didn`t understand all text because of my weak english.

I have unique ID for every house. I make dynamic pickup? And when i enter then my variable:
Pickup..Unique..[playerid] = HouseID;

How it teleports me into house?
Can you make examples, please :P
Reply
#5

(if) your house system looks like
Код:
#define MAX_HOUSES 10000

new HouseOwner[MAX_HOUSES][MAX_PLAYER_NAME];
new HouseEnterPickup[MAX_HOUSES];
new HousePickupLinksToHouseID[MAX_HOUSES];
...then create a house for sale:
Код:
new id=12;//any house id, maybe serialized in a loop when loading, or Houses+1; when creating a new house.
new pick=CreateDynamicPickup(blablabla);//will return a pickupid like 134 - make sure that the max_pickups #define/array is ALWAYS bigger!
HouseEnterPickup[pick==134]=id;//134th pickup gets assigned the 12, as its pointing to the 12th house.
HousePickupLinksToHouseID[HouseEnterPickup[id]==134]=2070;// HouseEnterPickup[id] = 134 and 2070 is the target interior of the house
later, HouseEnterPickup[id] will get replaced by pickupid - it will serve as pointer to your houseid directly: HousePickupLinksToHouseID[pickupid]...
now a command to buy a house by setting the HouseOwner[HouseID] array to the players' name. lets say, (3)Babul will buy a house in pricke pine, and the houses interior ID is 2070:
you will need to use the OnPlayerPickUpDynamicPickup() callback and pickupid. since the entrances are using pickups, the pickups' id of the last (recently) touched pickup will be stored in a player variable.
btw: the pickup callback gets triggered each 2 or 3 seconds, as long you are standing in a pickup all time - this makes any timer obsolete.
Код:
//either a callback or command using playerid. not to forget the (P)Var set previously in the pickup callback. (when a player stepped into the pickup at the door)
new Name[MAX_PLAYER_NAME];
GetPlayerName(playerid,Name,sizeof(Name));
//now, the magic trick:
new pickupid=GetPVarInt(playerid,"PickupIDTouched");//see below... this is NOT meant to be in the pickup callback, thats why i need to create a pickupid.
new HouseID=HousePickupLinksToHouseID[pickupid];//remember when writing into cell HouseEnterPickup[id]=134 ? pickupid==134 now, so it "Links" to the cell 134's element, which contains 2070. the houses' interior!
HouseOwner[HouseID]=Name;//HouseID==2070 - lets assume i got enough cash. always test it without any limitations
now its time for the streamer plugin to do the dirty work for you (returning the pickupid you are touching):
Код:
forward OnPlayerPickUpDynamicPickup(playerid,pickupid);						public OnPlayerPickUpDynamicPickup(playerid,pickupid){
{
	SetPVarInt(playerid,"PickupIDTouched",pickupid);
	return 1;
}
lets resume:
the 12th house (interior 2070) pickup got created, its the 134th pickup on the map.
when a player touches it, the pickupid will be the n-th pickupid (134) in the callback
if HouseEnterPickup[pickupid=134] links to a house id (>0 for a valid house), used as pointer in HousePickupLinksToHouseID[], then the resulting branch could be "decoded" as
HousePickupLinksToHouseID[HouseEnterPickup[pickupid==134]==12]==2070

this system is volatile to bugs, you need to polish it up a bit.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)