Help with a "pickup"
#1

Hi guys! I want to do something to my PropertyCreate System.

First of all this is the command /ahouseentrance (to create a house)

Code:
	if(strcmp(cmd, "/ahouseentrance", true) == 0)
	{
	    if(IsPlayerConnected(playerid))
	    {
			tmp = strtok(cmdtext, idx);
			if(!strlen(tmp))
			{
				SendClientMessage(playerid, COLOR_GRAD2, "{AFAFAF}SYNTAX{FFFFFF}: /ahouseentrance [houseid]");
				return 1;
			}
			new id = strval(tmp);
			if(PlayerInfo[playerid][pAdministrator] >= 4)
			{
			    //new pmodel;
				new Float:x,Float:y,Float:z;
				GetPlayerPos(playerid, x, y, z);
				Houses[id][EnterX] = x;
				Houses[id][EnterY] = y;
				Houses[id][EnterZ] = z;
				Houses[id][EnterWorld] = GetPlayerVirtualWorld(playerid);
				Houses[id][EnterInterior] = GetPlayerInterior(playerid);
  				new Float:angle;
				GetPlayerFacingAngle(playerid, angle);
				Houses[id][EnterAngle] = angle;
    			SaveHouses(id);
				new form[128];
				format(form, sizeof(form), "You have set House ID: %d's location", id);
				SendClientMessage(playerid, COLOR_ADMINCMD, form);
				Move3DTextLabel(housetext[id], string, 0xF0F8FFAA, x, y, z);
				SaveHouses(id);
			}
			else
			{
				SendClientMessage(playerid, COLOR_GREY, "   Nu esti autorizat sa folosesti aceasta comanda.");
			}
		}
		return 1;
	}
So.. I want to create a different pickup if the house is not bought and if it's bought another different pickup.

How can I do that? Can u help me? Thanks.
Reply
#2

There are lots of ways you can do this with,
but the most simple is add a couple of variable inside your House enum
PHP Code:
enum /*Whatever your house enum is called*/{
       
/*
       ...
       ...
       ...
       Whatever other variables you already have
       */
,
       
bool:Owned,
       
PickupID
}; 
by default, the Houses[id][Owned] would be equal to false,
OK, now, the House would initially not be Owned, thus
PHP Code:
Houses[id][Owned] = false 
when someone buys the house /buyhouse /purchasehouse ....etc you should set the value to true then (basic logic)
PHP Code:
Houses[id][Owned] = true 
OK, now that we have the Owned variable set, let's work around making dynamic pickups that changes whether the house is owner or not,

let's use pickup ID 1273 for not owned houses
and ID 1272 for owned houses

PHP Code:
       //Create a variable, and give ite the value of 1272 if the House is owned, if not, give it the value of 1273 
       
new pickupModel = (Houses[id][Owned]) ? 1272 1273//(Ternary Operature)
       //Check if the house pickup already exist, if so, destroy it
       
if(House[id][PickupID])
              
DestroyPickup(House[id][PickupID]);
       
//Create a new Pickup with the model ID pickupModel
       
Houses[id][PickupID] = CreatePickup(pickupModel21503.33591432.358510.1191, -1); 
References:
Ternary Operator: https://developer.mozilla.org/en/doc...ional_Operator
Pickup Creation Function https://sampwiki.blast.hk/wiki/CreatePickup
A list of available pickups http://dev.prineside.com/en/gtasa_sa...ups-and-icons/
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)