How can i replace a pick up
#1

Well when i create a house a green house icon appears ( the static pick up ) but when i buy it i make a blue house icon appear ( a static pick up )


How can i make the green one go away and the blue one replace it when a player buys the house


pawn Код:
CMD:createhouse(playerid,params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,-1,"You aren't an admin!");//Check if the player is currently rcon logged in.
    new HousePrice,id = HouseCount;//Creating the house price for the selected value in the command, and the last house id created.
    if(sscanf(params,"i",HousePrice)) return SendClientMessage(playerid,-1,"USAGE: /createhouse [price]");//Checking if the player uses the correct syntax. The parameter "i" in sscanf means integer, also could be used as "d".
    new Float:x,Float:y,Float:z;//Creating the floats, to store the player's position.
    GetPlayerPos(playerid,x,y,z);//Getting the player's position and storing it
    HInfo[id][Price] = HousePrice;//Setting the house price to the selected one.
    HInfo[id][Owned] = 0;//Setting the house id owned = 0
    HInfo[id][XPos] = x;//Storing the XPos value to the player's x.
    HInfo[id][YPos] = y;//Storing the YPos value to the player's y.
    HInfo[id][ZPos] = z;//Storing the ZPos value to the player's z.
    HInfo[id][VirtualWorld] = GetPlayerVirtualWorld(playerid);
    format(HInfo[id][Owner],24,"Nonusablenameforthishouse");//Formating the "Owner" house id value to "Nonusablenameforthishouse".
    SendClientMessage(playerid,-1,"House created");
    HouseEnter[id] = AddStaticPickup(1273, -1, x, y, z, 0);//Creating the checkpoint and storing it in the HouseEnter value.
    HouseExit[id] = CreateDynamicCP(443.9237,509.4609,1001.4195,1.5,GetPlayerVirtualWorld(playerid));//Creating the house exit checkpoint and storing it in the HouseExit value.
    new INI:File = INI_Open(UserPath(playerid));
    INI_SetTag(File, "House");
    INI_WriteInt(File,"Price",HousePrice);//Writing in the place "Price" the inputted "Price" value.
    INI_WriteInt(File,"Owned",0);//Setting to "Owned" = 0 in the ini file.
    INI_WriteInt(File,"VirtualWorld",GetPlayerVirtualWorld(playerid));//Writing "VirtualWorld" = GetPlayerVirtualWorld(..);
    INI_WriteFloat(File,"XPos",x);//Writing the players pos for the check point position.
    INI_WriteFloat(File,"YPos",y);//Self explanatory.
    INI_WriteFloat(File,"ZPos",z);//Self explanatory.
    INI_WriteString(File,"Owner","Nonusablenameforthishouse");//Writing a string in "Owned" to "Nonusablenameforthishouse"
    INI_Close(File);//Closing the file with SII.
    HouseCount++;
    return 1;
}

CMD:buy(playerid,params[])
{
    for(new i = 0; i < MAX_HOUSES;i++)//Loop threw all houses.
    {
        if(!IsPlayerInRangeOfPoint(playerid,8.0,HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos])) continue;//Check if the player is near a house checkpoint
        if(GetPlayerMoney(playerid) < HInfo[i][Price]) return SendClientMessage(playerid,-1,"You don't have enough money");//Checking the players money, to see if he has enough to buy the house.
        if(HInfo[i][Owned] == 1) return SendClientMessage(playerid,-1,"This house is already owned");//Checking if the house is already owned.
        AddStaticPickup(1272, -1, HInfo[i][XPos],HInfo[i][YPos],HInfo[i][ZPos], 0);
        HInfo[i][Owned] = 1;//Setting the house owned var to 1.
        GameTextForPlayer(i, "Bought!", 3000, 1);
        GetPlayerName(playerid,pname,sizeof(pname));//Retrieving the player's name.
        new INI:File = INI_Open(UserPath(playerid));
        INI_WriteInt(File, "Owned",1);//Setting in the ini file "Owned" to 1
        INI_WriteString(File, "Owner",pname);//Setting the "Owner" to the player's name.
        INI_Close(File);//Closing the ini
        return 1;
    }
    SendClientMessage(playerid,-1,"You aren't near a house!");
    return 1;
}

Thank You


Please Help Me Please
Reply
#2

im not giving you code here as you should by now be capable of searching and using the wiki for these answers

but heres the hint
pawn Код:
HouseEnter[id] = AddStaticPickup(1273, -1, x, y, z, 0);//Creating the checkpoint and storing it in the HouseEnter value.
you need to destroy this pickup when someone buys and then create a new one with the blue house icon!
1273 is the id of your current house icon,
that will need changed.

regards,

also you should not use AddStaticPickup
heres the links youll need.
https://sampwiki.blast.hk/wiki/CreatePickup
https://sampwiki.blast.hk/wiki/DestroyPickup
Reply
#3

Quote:
Originally Posted by Jonny5
Посмотреть сообщение
im not giving you code here as you should by now be capable of searching and using the wiki for these answers

but heres the hint
pawn Код:
HouseEnter[id] = AddStaticPickup(1273, -1, x, y, z, 0);//Creating the checkpoint and storing it in the HouseEnter value.
you need to destroy this pickup when someone buys and then create a new one with the blue house icon!
1273 is the id of your current house icon,
that will need changed.

regards,

also you should not use AddStaticPickup
heres the links youll need.
https://sampwiki.blast.hk/wiki/CreatePickup
https://sampwiki.blast.hk/wiki/DestroyPickup
I know but when the blue icon appears it is pretty much on in the same posotion with the green one which shows blue and green


Thank You


Please Help Me Please
Reply
#4

this is why you must destroy the old pick up!
go back and read what i wrote in my first post,
it has all the info you need!
Reply
#5

This did not work


pawn Код:
CMD:createhouse(playerid, params[])
{
        new pickup = AddStaticPickup(1273, -1, x, y, z, 0);
        HouseEnter[id]  = pickup;
}


CMD:buy(playerid, params[])
{
        DestroyPickup(pickup);
}

Thank You


Please Help Me Please
Reply
#6

Thank You


Please Help Me Please
Reply
#7

Read some documentation about the scope of variables.
Reply
#8

Quote:
Originally Posted by Vince
Посмотреть сообщение
Read some documentation about the scope of variables.
Been reading i still cant figure it out


Thank You


Please Help Me Please
Reply
#9

Thank You


Please Help Me Please
Reply
#10

well you need to read more,
you should try to trouble shoot these easy things yourself,
it will only help you be a better scripter!
You have been on the forums for some time, and should know these basic things!.

pawn Код:
CMD:createhouse(playerid, params[])
{
       HouseEnter[id]  = AddStaticPickup(1273, -1, x, y, z, 0);
}


CMD:buy(playerid, params[])
{
        DestroyPickup(HouseEnter[id]);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)