SA-MP Forums Archive
Annoying problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Annoying problem (/showthread.php?tid=175045)



Annoying problem - mrcoolballs - 08.09.2010

Okay I got this straight for [HiC]TheKiller's tutorial there were alot of problems in that tutorial, I have fixed up most of them but now theres one left and I have been working all week to try and fix it with no luck.

Anyone help me out?

pawn Код:
public OnPlayerPickUpPickup(playerid,pickupid) //If you have one of these add the stuff in this to your on‌e =]
{
    for(new C; C<BusinessCount; C++)
    {  
        if(pickupid == BusinessPickup[C]) //Checks if the pickup is for a business
        {
            new str[150];
            if(BusinessInfo[C][BusOwner] == -1) format(str, sizeof(str), "%s ~n~~r~Cost price: $%d ~b~Sale price: $%d ~n~ ~g~Earn ammount: $%d", BusinessInfo[C][BusName], BusinessInfo[C][BusCost], BusinessInfo[C][BusSell], BusinessInfo[C][BusEarn]); //Makes the string for a business with no owner.
            if(BusinessInfo[C][BusOwner] != -1)
            {
               
                new Pname[24]; //Creates player name variable
                GetPlayerName(BusinessInfo[C][BusOwner], Pname, 24); //Gets player name
                format(str, sizeof(str), "%s ~n~~r~Cost price: $%d ~b~Sale price: $%d ~n~ ~g~Earn ammount: $%d~n~~w~Owner: %s(%d)", BusinessInfo[C][BusName], BusinessInfo[C][BusCost], BusinessInfo[C][BusSell], BusinessInfo[C][BusEarn], Pname, BusinessInfo[C][BusOwner]);
                SendClientMessage(playerid,0x00FF00AA,str);
            }
        }  
    }
    return 1;
}
When I walk into a pickup it displays nothing


Re: Annoying problem - Norn - 08.09.2010

The pickup type is probably not correct, I'd recommend just using a timer with gametexts.


Re: Annoying problem - Rachael - 08.09.2010

for things like this I just use a proximity check in a function called by a repeating 2 second timer. It saves having to re-create the pickup.


Re: Annoying problem - Backwardsman97 - 08.09.2010

Try it like this.

pawn Код:
public OnPlayerPickUpPickup(playerid,pickupid) //If you have one of these add the stuff in this to your on‌e =]
{
    for(new C; C<BusinessCount; C++)
    {
        if(pickupid == BusinessPickup[C]) //Checks if the pickup is for a business
        {
            new str[150];
            if(BusinessInfo[C][BusOwner] == -1)
            {
                format(str, sizeof(str), "%s ~n~~r~Cost price: $%d ~b~Sale price: $%d ~n~ ~g~Earn ammount: $%d", BusinessInfo[C][BusName], BusinessInfo[C][BusCost], BusinessInfo[C][BusSell], BusinessInfo[C][BusEarn]); //Makes the string for a business with no owner.
                SendClientMessage(playerid,0x00FF00AA,str);
                return 1;
            }
            else
            {
                new Pname[24]; //Creates player name variable
                GetPlayerName(BusinessInfo[C][BusOwner], Pname, 24); //Gets player name
                format(str, sizeof(str), "%s ~n~~r~Cost price: $%d ~b~Sale price: $%d ~n~ ~g~Earn ammount: $%d~n~~w~Owner: %s(%d)", BusinessInfo[C][BusName], BusinessInfo[C][BusCost], BusinessInfo[C][BusSell], BusinessInfo[C][BusEarn], Pname, BusinessInfo[C][BusOwner]);
                SendClientMessage(playerid,0x00FF00AA,str);
                return 1;
            }
        }
    }
    return 1;
}
I think the reason it may not be showing anything is because there may not be an owner. This way, it will show regardless.


Re: Annoying problem - mrcoolballs - 08.09.2010

how would i use a proximity check? and yes the pickupid is correct here is the line that confirms it:

pawn Код:
BusinessPickup[BusinessCount] = AddStaticPickup(1272, 1, XPos, YPos, ZPos, -1);
Backwardsman i tried it and with no luck it didnt work


Re: Annoying problem - bigcomfycouch - 08.09.2010

AddStaticPickup returns 1 when it creates a pickup. Use CreatePickup, it returns the ID of the created pickup.


Re: Annoying problem - Rachael - 08.09.2010

Код:
forward CustomPickups();
...
SetTimer("CustomPickups",2000,true);
...
public CustomPickups()
{
for(new i = 0;i < MAX_PLAYERS;i++)
{
if(PlayerToPoint(2.0,i,0.0,0.0,0.0)) //insert pickup co-ordinates here
{
GameTextForPlayer(i,"bla bla",2000,3);
}
else if(PlayerToPoint(2.0,i,0.0,0.0,0.0))
{
GameTextForPlayer(i,"bla bla",2000,3);
}
}
return 1;
}

...

stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
if(IsPlayerConnected(playerid))
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
if(SpectateVehicle[playerid])
GetPlayerPos(playerid,oldposx,oldposy,oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
}
return 0;
}
note: this is just a quick copy paste without indentation or error checking, but you should get the idea.


Re: Annoying problem - Backwardsman97 - 08.09.2010

I think that will just confuse him because that's not what he's trying to do. Just use CreatePickup and it should work fine.


Re: Annoying problem - bigcomfycouch - 08.09.2010

Quote:
Originally Posted by Rachael
Посмотреть сообщение
for things like this I just use a proximity check in a function called by a repeating 2 second timer. It saves having to re-create the pickup.
If the pickup type is 1 it doesn't disappear when it's picked up.