SA-MP Forums Archive
Getting Help with Trashmaster Back Coordinate - 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)
+--- Thread: Getting Help with Trashmaster Back Coordinate (/showthread.php?tid=436969)



Getting Help with Trashmaster Back Coordinate - Gaurav_Rawat - 13.05.2013

Hello There !

I would like to get a little help from you guys
I just got stucked somewhere i hope someone from you can help me out

I want the player should stand at the back of the vehicle and then only the system should work currently it works near the door of the vehicle

Here is my code please help me


pawn Код:
if((newkeys & KEY_FIRE) && GetPlayerState(playerid) == PLAYER_STATE_ONFOOT)
    {
        new Float:cx, Float:cy, Float:cz;
        GetVehiclePos(oldcar[playerid], cx, cy, cz);
        if(IsPlayerInRangeOfPoint(playerid, 3, cx, cy, cz) && GetVehicleModel(oldcar[playerid]) == 408)
        {
            if(PlayerInfo[playerid][pJob] == 25 && HoldingObject[playerid] == 2)
            {

                GivePlayerCash(playerid, 30);
                        new string[256];
                RemovePlayerAttachedObject(playerid, 0);
                HoldingObject[playerid] = 0;
                format(string, sizeof(string), " %s places the trash bag into the garbage truck", GetPlayerNameEx(playerid));
                ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);



Re: Getting Help with Trashmaster Back Coordinate - RoleplayEditor - 14.05.2013

Maybe adjust your
GetVehiclePos(oldcar[playerid], cx, cy, cz);
if(IsPlayerInRangeOfPoint(playerid, 3, cx, cy, cz)


Re: Getting Help with Trashmaster Back Coordinate - Abhishek. - 14.05.2013

checking the vehicles angle woud work a bit not sure how


Re: Getting Help with Trashmaster Back Coordinate - Gaurav_Rawat - 14.05.2013

I already tried brothers,Maybe a example or if you could show me how to do it would help me alot !


Re: Getting Help with Trashmaster Back Coordinate - -CaRRoT - 14.05.2013

PHP код:
if(IsPlayerInRangeOfPoint(playerid3cxcycz) && GetVehicleModel(oldcar[playerid]) == 408
Increase the 3 to 5.0 - It will work.


Re: Getting Help with Trashmaster Back Coordinate - MP2 - 14.05.2013

He wants to detect if you're at the BACK of the trashmaster - not anywhere around it!

Put this in 'offset.inc' and include it: http://pastebin.com/XmED67FC

The trashmaster's y offset for the back is -4.5:

pawn Код:
new Float:x, Float:y, Float:z;
GetVehiclePos(vehicleid, x, y, z);
GetOffset(x, y, z, a, 0, -4.5, 0, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 2.0, x, y, z))
{
    // They are at the back of the trashmaster
}
(Un-tested)


Re: Getting Help with Trashmaster Back Coordinate - Gaurav_Rawat - 14.05.2013

@MP2
In the line
GetOffset(x, y, z, a, 0, -4.5, 0, x, y, z);
a is giving me error i guess its the angle should i use 0 or just remove it ?


Re: Getting Help with Trashmaster Back Coordinate - MP2 - 14.05.2013

What error..? The angle needs to be the vehicle's angle. I forgot about that. Use this:

pawn Код:
new Float:x, Float:y, Float:z, Float:a;
GetVehiclePos(vehicleid, x, y, z);
[B]GetVehicleZAngle(vehicleid, a);
GetOffset(x, y, z, a, 0, -4.5, 0, x, y, z);
if(IsPlayerInRangeOfPoint(playerid, 2.0, x, y, z))
{
    // They are at the back of the trashmaster
}