SA-MP Forums Archive
Command Help - 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: Command Help (/showthread.php?tid=247593)



Command Help - Tommy_Mandaz - 10.04.2011

Hello, I am trying to make a /pickup command like this:

pawn Код:
if(strcmp("/pickup", cmdtext, true) == 0)
    {
        if(IsPlayerConnected(playerid))
        {
                        if(!IsPlayerInVehicle(playerid, GetPlayerVehicleID(playerid)))
                        {
                               if(IsPlayerInRangeOfPoint(playerid, 3.0, gunobjectx, gunobjecty, gunobjectz);
                   {
                           GivePlayerWeapon(playerid, 23, 10);
                               }
                        }
                }
         }
My only problem is there is more then one gunobject how can I make it check which gun object he is standing on? Thanks


Re: Command Help - ihatetn931 - 10.04.2011

You can make a gunobject for each.

like
gunobject1x //same with y and z
gunobejct2x //same with y and z


Re: Command Help - Tommy_Mandaz - 10.04.2011

The problem is it creates the object within the script so when he does /drop it creates this:

pawn Код:
new Float:gunobjectx, Float:gunobjecty, Float:gunobjectz;
GetPlayerPos(playerid, gunobjectx, gunobjecty, gunobjectz);
CreateObject(320, gunobjectx, gunobjecty, gunobjectz, 0,0,0);
So how would I do it then?


Re: Command Help - ihatetn931 - 10.04.2011

Quote:
Originally Posted by Tommy_Mandaz
Посмотреть сообщение
The problem is it creates the object within the script so when he does /drop it creates this:

pawn Код:
new Float:gunobjectx, Float:gunobjecty, Float:gunobjectz;
GetPlayerPos(playerid, gunobjectx, gunobjecty, gunobjectz);
CreateObject(320, gunobjectx, gunobjecty, gunobjectz, 0,0,0);
So how would I do it then?
You could make a variable, Then use that variable to get the object id
pawn Код:
new GUN[MAX_PLAYERS]
pawn Код:
GUN[playerid] = CreateObject(320, gunobjectx, gunobjecty, gunobjectz, 0,0,0);
printf("%s",Gun[playerid]);
If i'm correct, That should return the object id. You could do a printf to see what its putting out.

Then you use what the printf put out (it prints in the server window)
pawn Код:
If(GUN[playerid] == id that printed)
{
//You would do your pickup code here
}
That would take sometime, I'm taking it this is dynamic if it is, This may not work

May i see your /drop command?


Re: Command Help - Tommy_Mandaz - 10.04.2011

Sure thing you can use it hopefully I can get the /pickup thing in though...


Re: Command Help - Tommy_Mandaz - 10.04.2011

bump


Re: Command Help - Tommy_Mandaz - 10.04.2011

Bump Help?