Quote:
Originally Posted by Calisthenics
You can avoid the 2 loops if you use streamer. In data manipulation, there is an item in enumerator called E_STREAMER_EXTRA_ID. When you create the pickup for the first time, set the array index to it. I'll give an example:
pawn Код:
// looping through all rows // create a global variable and set value equal to the houses loaded. // Let's call it "HousesLoaded". Say you have loaded 1500 houses so "HousesLoaded" is equal to 1500 House[i][Pickup] = CreateDynamicPickup(...); Streamer_SetIntData(STREAMER_TYPE_PICKUP, House[i][Pickup], E_STREAMER_EXTRA_ID, i + 2000); // native Streamer_SetIntData(type, id, data, value);
Streamer_SetIntData returns 0 if none is set, I think. This is one of the reason I did not use "i" as value but used "i + 2000" instead. You may use it in other systems so you need a way to recognize what type of pickup it is. You can use values to identify. In this case, 2000 + MAX_HOUSES, 4000 + MAX_SOMETHING_ELSE etc.
There is entrance pickup, when OnPlayerPickUpDynamicPickup is called you check for the type.
pawn Код:
// native Streamer_GetIntData(type, id, data); new extra_id = Streamer_GetIntData(STREAMER_TYPE_PICKUP, House[i][Pickup], E_STREAMER_EXTRA_ID);
// now we want to check if subtracting 2000 from it will give us a range of 0-HousesLoaded. if (0 <= (extra_id - 2000) <= HousesLoaded) { // okay, the type of pickup is house. alternative way might be to check the pickup modelid. // now we'll store to another global variable the last house. Player[playerid][Last_House] = extra_id - 2000;
// whenever you want to check now if the player is near a house, you can check if the player is in range with the last house // you know the house index and you know the position
// show dialog to submit or cancel }
Now on dialog response, you apply the same method. You know the last house the player pickup.
|
I actually used a similar system before (i was checking if the pickup id was between the first loaded pickup of house #1 and the last loaded pickup of the last loaded house #n, and then i did something like pickupid modulus 2, since i have 2 pickups at each house, to determine whether the player is at the entrance or at the exit of the house), but i was told by someone on the forum that pickups might not always be consistent with their ids, for example when a house is purchased it must change its pickup icon (so i delete the old one and create new), and players might be purchasing houses at the same time, so houses might mess up their pickup ids. Is this still a thing with the streamer method? Can i
really trust the pickup ids? And thank you for answer!
Edit: As i understood now,
Streamer_SetIntData can change ids of dynamic pickups?