Detecting a certain pickup.
#1

First of all, thank you for reading this.

Okie, what I am trying to do is a house system, but leave that, I only have a problem with the house icon pickup.

I am trying to make the house pickup be the green one when it's for sale and be the blue one when it is not for sale.
When I use /createhouse it will create the correct house icon ( green as it is for sale ) but then I can't check if the player is on the icon when he tries to do let's say /buyhouse.. ( Just started making the house system, it currently may only set and save the house positions and the price using dini. )

Anyway, anyone knows how may I detect on which pickup the player is currently at? Or if you have any other ways to do this.

Every post will be appreciated!

Thank you in advance.
Reply
#2

Use the callback OnPlayerPickUpPickup
Reply
#3

I already knew that, but how can I know on which pickup I am on?

Let's say I randomally created 15 house pickups, I don't know their coordinates as I randomally made them and I made them IG by a command.
Reply
#4

Firstly, create a variable for the pickup at the beggining of the gm:
pawn Код:
new pickupvar;
Then, go to OnGameModeInit and create the pickup:
pawn Код:
pickupvar = CreatePickup(blah, blah, blah);
After that, you can check the pickup on player pick up pickup:
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == pickupvar)
    {
        //do your code
    }
    return 1;
}
Reply
#5

Quote:
Originally Posted by Denying
Посмотреть сообщение
Anyway, anyone knows how may I detect on which pickup the player is currently at?
So your question is, which pickup the player is currently at.
That's easy if you ever used pickups, usually you'd have to use a variable to define the pickup ID, the samp wiki page explains a lot.
Any ways for example
pawn Код:
new mypickup; // The variable which we will store the pickup id within, this should be under the includes
Now in order for the pickup to be created
pawn Код:
//This will create a pickup at those coords, this should be put in OnGameModeInIt
mypickup= CreatePickup(1242, 3, 143.3359, 452, 754, -1);
Now to detect if the player entered that certant pickup, we'd use the call back OnPlayerPickUpPickup
In this case it would look somethning like this
pawn Код:
public OnPlayerPickUpPickup(playerid, pickupid)
{
    if(pickupid == mypickup)
    {
        SendClientMessage(playerid,-1,"You have entered a pickup called (mypickup)"
    }
    return 1;
}
Reply
#6

I got the idea, but let's go a little bit more advanced.

Let's take the following and try to make it compatible with what you just said;

pawn Код:
if (strcmp("/createhouse", cmdtext, true, 10) == 0)
    {
        new Float:x, Float:y, Float:z;
        GetPlayerPos(playerid, x, y, z);
        CreatePickup(1273, 1, x, y, z, 0);
        return 1;
    }
I think I can't store 50 pickup ids in the same variable, correct me if I am wrong.

By the way, I feel bad somehow I don't know why; sorry if I somehow made you feel like "Do this do that".
Just looking for the way to make this ( This will solve so many things )
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)