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



Stretcher Command - LucasAdams - 06.09.2015

Hi guys,

I'm trying to make a stretcher command and I'm having some issues.

When you drop the stretcher, it doesn't face the angle the player is facing, it faces the same position every time.

No matter where I am looking, the head of the stretcher will always face WEST.

PHP код:
CMD:stretcher(playeridparams[])
{
    static
        
type[24],
        
Float:x,
        
Float:y,
        
Float:z,
        
Float:angle;
        
    if (
GetFactionType(playerid) != FACTION_MEDIC)
        return 
SendErrorMessage(playerid"You do not have permission to use this command.");
    
    if (!
strcmp(type"get"true))
    {
        for (new 
0!= MAX_VEHICLES++) if (IsPlayerNearBoot(playeridi) && GetVehicleModel(i) == 416)
        {
            
SetPlayerAttachedObject(playerid119971, -1.1065041.5049880.0315840.00000089.5666350.000000);
        }
    }
    if (!
strcmp(type"drop"true))
    {
        
GetPlayerPos(playeridxyz);
        
GetPlayerFacingAngle(playeridangle);
         
RemovePlayerAttachedObject(playerid1);
        
CreateObject(1997xyz-10.00.00.050.0);
        
SetPlayerPos(playeridx-1yz);
    }
    return 
1;




Re: Stretcher Command - Fancy - 06.09.2015

Try this:

Код:
CMD:stretcher(playerid, params[]) 
{ 
    static 
        type[24], 
        Float:x, 
        Float:y, 
        Float:z, 
        Float:angle; 
         
    if (GetFactionType(playerid) != FACTION_MEDIC) 
        return SendErrorMessage(playerid, "You do not have permission to use this command."); 
     
    if (!strcmp(type, "get", true)) 
    { 
        for (new i = 0; i != MAX_VEHICLES; i ++) if (IsPlayerNearBoot(playerid, i) && GetVehicleModel(i) == 416) 
        { 
            SetPlayerAttachedObject(playerid, 1, 1997, 1, -1.106504, 1.504988, 0.031584, 0.000000, 89.566635, 0.000000); 
        } 
    } 
    if (!strcmp(type, "drop", true)) 
    { 
        GetPlayerPos(playerid, x, y, z); 
        GetPlayerFacingAngle(playerid, angle); 
        RemovePlayerAttachedObject(playerid, 1); 
        CreateObject(1997, x, y, angle, 0.0, 0.0, 0.0, 50.0); 
        SetPlayerPos(playerid, x-1, y, z); 
    } 
    return 1; 
}



Re: Stretcher Command - LucasAdams - 06.09.2015

Quote:
Originally Posted by Fancy
Посмотреть сообщение
Try this:

Код:
CMD:stretcher(playerid, params[]) 
{ 
    static 
        type[24], 
        Float:x, 
        Float:y, 
        Float:z, 
        Float:angle; 
         
    if (GetFactionType(playerid) != FACTION_MEDIC) 
        return SendErrorMessage(playerid, "You do not have permission to use this command."); 
     
    if (!strcmp(type, "get", true)) 
    { 
        for (new i = 0; i != MAX_VEHICLES; i ++) if (IsPlayerNearBoot(playerid, i) && GetVehicleModel(i) == 416) 
        { 
            SetPlayerAttachedObject(playerid, 1, 1997, 1, -1.106504, 1.504988, 0.031584, 0.000000, 89.566635, 0.000000); 
        } 
    } 
    if (!strcmp(type, "drop", true)) 
    { 
        GetPlayerPos(playerid, x, y, z); 
        GetPlayerFacingAngle(playerid, angle); 
        RemovePlayerAttachedObject(playerid, 1); 
        CreateObject(1997, x, y, angle, 0.0, 0.0, 0.0, 50.0); 
        SetPlayerPos(playerid, x-1, y, z); 
    } 
    return 1; 
}
Why does angle replace z? Shouldn't it replace the rotation values?


Re: Stretcher Command - Fancy - 06.09.2015

Alright try this

Код:
CMD:stretcher(playerid, params[]) 
{ 
    static 
        type[24], 
        Float:x, 
        Float:y, 
        Float:z, 
        Float:angle; 
         
    if (GetFactionType(playerid) != FACTION_MEDIC) 
        return SendErrorMessage(playerid, "You do not have permission to use this command."); 
     
    if (!strcmp(type, "get", true)) 
    { 
        for (new i = 0; i != MAX_VEHICLES; i ++) if (IsPlayerNearBoot(playerid, i) && GetVehicleModel(i) == 416) 
        { 
            SetPlayerAttachedObject(playerid, 1, 1997, 1, -1.106504, 1.504988, 0.031584, 0.000000, 89.566635, 0.000000); 
        } 
    } 
    if (!strcmp(type, "drop", true)) 
    { 
        GetPlayerPos(playerid, x, y, z); 
        GetPlayerFacingAngle(playerid, angle); 
        RemovePlayerAttachedObject(playerid, 1); 
        CreateObject(1997, x, y, z-1, 0.0, 0.0, 0.0, 50.0); 
        SetObjectRot(objectid, x, y, angle);
        SetPlayerPos(playerid, x-1, y, z); 
    } 
    return 1; 
}



Re: Stretcher Command - LucasAdams - 06.09.2015

Nope, that's having no effect


AW: Stretcher Command - Nero_3D - 06.09.2015

The whole command is broken, completely rewritten, now it simply gets a stretcher if you a near an ambulance and drops it if you have it attached
pawn Код:
CMD:stretcher(playerid, unused[]) {
    #pragma unused unused

    if(GetFactionType(playerid) != FACTION_MEDIC) {
        return SendErrorMessage(playerid, "You do not have permission to use this command.");
    }
    new
        Float: X,
        Float: Y,
        Float: Z
    ;
    GetPlayerPos(playerid, X, Y, Z);

    if(IsPlayerAttachedObjectSlotUsed(playerid, 1)) {
        new
            Float: A
        ;
        GetPlayerFacingAngle(playerid, A);
        CreateObject(1997, X - floatsin(A, degrees), Y + floatcos(A, degrees), Z - 1.0, 0.0, 0.0, A, 50.0);
        RemovePlayerAttachedObject(playerid, 1);
    } else {
        for (new i = 1; i <= MAX_VEHICLES; i++) { // vehicleid start at 1
            if (GetVehicleModel(i) == 416 && GetVehicleDistanceFromPoint(i, X, Y, Z) < 10.0) {
                SetPlayerAttachedObject(playerid, 1, 1997, 1, -1.106504, 1.504988, 0.031584, 0.000000, 89.566635, 0.000000);
                return true; // stop the loop
            }
        }
        SendClientMessage(playerid, -1, "You need to be next to an ambulance");
    }
    return true;
}



Re: AW: Stretcher Command - Luke_James - 06.09.2015

Thank you, could you possibly explain how you made it work?


AW: Re: AW: Stretcher Command - Nero_3D - 06.09.2015

Quote:
Originally Posted by Luke_James
Посмотреть сообщение
Thank you, could you possibly explain how you made it work?
To make it work you simply had to add the Z rotation in the line
pawn Код:
CreateObject(1997, x, y, z-1, 0.0, 0.0, angle, 50.0);
But the main problem was the code itself
- The type variable was empty, resulting that both strcmp statements were always true
- IsPlayerNearBoot was used in the loop although it should be an ambulance
- It never checked in the drop part if the player even has something attached

@ Wrong person I guess but both start with "Lu" :S