SetPlayerAttachedObject Not showing object ?
#1

Hi all, I have a problem with my SetPlayerAttachedObject ? When I do a command to attach like a Police vest it dosnt show the object. Would this be a problem of to many objects of mapping in the server ?

pawn Код:
CMD:attachvest(playerid, params[])
{
    for(new x;x<MAX_PLAYERTOYS;x++)
    {
        SetPlayerAttachedObject(playerid, x, 19142, 1, 0.07998, 0.03999, 0.0, 0.0, 0.0, 0.0, 1, 1, 1);
    }
    return 1;
}
I do that command in game and it dosnt spawn the vest ?
Reply
#2

pawn Код:
CMD:attachvest(playerid,params[])
{
    if(IsPlayerAttachedObjectSlotUsed(playerid, 0))
    {
        RemovePlayerAttachedObject(playerid, 0);
    }
    SetPlayerAttachedObject(playerid, 0, 19142, 1, 0.07998, 0.03999, 0.0, 0.0, 0.0, 0.0, 1, 1, 1);
    return 1;
}
Give that a try.
Reply
#3

Quote:
Originally Posted by clarencecuzz
Посмотреть сообщение
pawn Код:
CMD:attachvest(playerid,params[])
{
    if(IsPlayerAttachedObjectSlotUsed(playerid, 0))
    {
        RemovePlayerAttachedObject(playerid, 0);
    }
    SetPlayerAttachedObject(playerid, 0, 19142, 1, 0.07998, 0.03999, 0.0, 0.0, 0.0, 0.0, 1, 1, 1);
    return 1;
}
Give that a try.
Nope
Reply
#4

it spawns for a quick second and instantly removes itself
Reply
#5

CMD:attachvest(playerid,params[])
{
if(IsPlayerAttachedObjectSlotUsed(playerid, 0))
{
RemovePlayerAttachedObject(playerid, 0);
return 1;
}
SetPlayerAttachedObject(playerid, 0, 19142, 1, 0.07998, 0.03999, 0.0, 0.0, 0.0, 0.0, 1, 1, 1);
return 1;
}

what now?
Reply
#6

No, because then if you already had an object attached, it would never spawn the vest...

pawn Код:
CMD:attachvest(playerid,params[])
{
    if(IsPlayerAttachedObjectSlotUsed(playerid, 0))
    {
        RemovePlayerAttachedObject(playerid, 0);
        SetPlayerAttachedObject(playerid, 0, 19142, 1, 0.07998, 0.03999, 0.0, 0.0, 0.0, 0.0, 1, 1, 1);
        return 1;
    }
    SetPlayerAttachedObject(playerid, 0, 19142, 1, 0.07998, 0.03999, 0.0, 0.0, 0.0, 0.0, 1, 1, 1);
    return 1;
}
If this doesn't work, most likely nothing will. It may be due to objects, make sure you use a streamer.
Reply
#7

I found the issue it wasn't mapping but I still dont have a solution, willing to give +REP to Anyone who can help me out

Okay the problem is with my command is it spawns for a second and then removes it self. I know why its removing itself because OnPlayerUpdate im using this script i found on the forums where it attachs weapons to a players body and I think this might be a issue with the ves!

pawn Код:
if(GetTickCount() - armedbody_pTick[playerid] > 113){ //prefix check itter
        new
            weaponid[13],weaponammo[13],pArmedWeapon;
        pArmedWeapon = GetPlayerWeapon(playerid);
        GetPlayerWeaponData(playerid,1,weaponid[1],weaponammo[1]);
        GetPlayerWeaponData(playerid,2,weaponid[2],weaponammo[2]);
        GetPlayerWeaponData(playerid,4,weaponid[4],weaponammo[4]);
        GetPlayerWeaponData(playerid,5,weaponid[5],weaponammo[5]);
        #if ARMEDBODY_USE_HEAVY_WEAPON
        GetPlayerWeaponData(playerid,7,weaponid[7],weaponammo[7]);
        #endif
        if(weaponid[1] && weaponammo[1] > 0){
            if(pArmedWeapon != weaponid[1]){
                if(!IsPlayerAttachedObjectSlotUsed(playerid,0)){
                    SetPlayerAttachedObject(playerid,0,GetWeaponModel(weaponid[1]),1, 0.199999, -0.139999, 0.030000, 0.500007, -115.000000, 0.000000, 1.000000, 1.000000, 1.000000);
                }
            }
            else {
                if(IsPlayerAttachedObjectSlotUsed(playerid,0)){
                    RemovePlayerAttachedObject(playerid,0);
                }
            }
        }
        else if(IsPlayerAttachedObjectSlotUsed(playerid,0)){
            RemovePlayerAttachedObject(playerid,0);
        }
        if(weaponid[2] && weaponammo[2] > 0){
            if(pArmedWeapon != weaponid[2]){
                if(!IsPlayerAttachedObjectSlotUsed(playerid,1)){
                    SetPlayerAttachedObject(playerid,1,GetWeaponModel(weaponid[2]),8, -0.079999, -0.039999, 0.109999, -90.100006, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000);
                }
            }
            else {
                if(IsPlayerAttachedObjectSlotUsed(playerid,1)){
                    RemovePlayerAttachedObject(playerid,1);
                }
            }
        }
        else if(IsPlayerAttachedObjectSlotUsed(playerid,1)){
            RemovePlayerAttachedObject(playerid,1);
        }
        if(weaponid[4] && weaponammo[4] > 0){
            if(pArmedWeapon != weaponid[4]){
                if(!IsPlayerAttachedObjectSlotUsed(playerid,2)){
                    SetPlayerAttachedObject(playerid,2,GetWeaponModel(weaponid[4]),7, 0.000000, -0.100000, -0.080000, -95.000000, -10.000000, 0.000000, 1.000000, 1.000000, 1.000000);
                }
            }
            else {
                if(IsPlayerAttachedObjectSlotUsed(playerid,2)){
                    RemovePlayerAttachedObject(playerid,2);
                }
            }
        }
        else if(IsPlayerAttachedObjectSlotUsed(playerid,2)){
            RemovePlayerAttachedObject(playerid,2);
        }
        if(weaponid[5] && weaponammo[5] > 0){
            if(pArmedWeapon != weaponid[5]){
                if(!IsPlayerAttachedObjectSlotUsed(playerid,3)){
                    SetPlayerAttachedObject(playerid,3,GetWeaponModel(weaponid[5]),1, 0.200000, -0.119999, -0.059999, 0.000000, 206.000000, 0.000000, 1.000000, 1.000000, 1.000000);
                }
            }
            else {
                if(IsPlayerAttachedObjectSlotUsed(playerid,3)){
                    RemovePlayerAttachedObject(playerid,3);
                }
            }
        }
        else if(IsPlayerAttachedObjectSlotUsed(playerid,3)){
            RemovePlayerAttachedObject(playerid,3);
        }
        #if ARMEDBODY_USE_HEAVY_WEAPON
        if(weaponid[7] && weaponammo[7] > 0){
            if(pArmedWeapon != weaponid[7]){
                if(!IsPlayerAttachedObjectSlotUsed(playerid,4)){
                    SetPlayerAttachedObject(playerid,4,GetWeaponModel(weaponid[7]),1,-0.100000, 0.000000, -0.100000, 84.399932, 112.000000, 10.000000, 1.099999, 1.000000, 1.000000);
                }
            }
            else {
                if(IsPlayerAttachedObjectSlotUsed(playerid,4)){
                    RemovePlayerAttachedObject(playerid,4);
                }
            }
        }
        else if(IsPlayerAttachedObjectSlotUsed(playerid,4)){
            RemovePlayerAttachedObject(playerid,4);
        }
        #endif
        armedbody_pTick[playerid] = GetTickCount();
    }
    return 1;
}
That coding is OnPlayerUpdate bugging my vest?
Reply
#8

Definitely.
pawn Код:
else {
                if(IsPlayerAttachedObjectSlotUsed(playerid,0)){
                    RemovePlayerAttachedObject(playerid,0);
                }
            }
        }
        else if(IsPlayerAttachedObjectSlotUsed(playerid,0)){
            RemovePlayerAttachedObject(playerid,0);
        }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)