SA-MP Forums Archive
Player3DText not showing, object not getting attached - 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: Player3DText not showing, object not getting attached (/showthread.php?tid=635994)



Player3DText not showing, object not getting attached - bencesz - 17.06.2017

What's wrong with this code?
It should be:
-When player enters a vehicle, 2 random objects and 3dtextlabels are created for him.
-When he is 1.0 dist. away from the object and presses left alt, he would be carrying the object (not the created one, but the same model), and the previously created objects (created just to indicate their position) would be destroyed, so do the textlabels.

PHP Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(
newstate == PLAYER_STATE_DRIVER)
    {
        if(
GetVehicleModel(vid) == 459)
        {   
// csomagszбllнtу
            
if(csomag_bepakolt[playerid] == 2)
            {
                
DisablePlayerCheckpoint(playerid);
                
csomagkihordo[playerid] = 3;
                new 
rand = random(sizeof(randomcsomag));
                
SetPlayerCheckpoint(playerid, randomcsomag[rand][0], randomcsomag[rand][1], randomcsomag[rand][2],3.0);
            }
            if(
csomag_bepakolt[playerid] == 0)
            {
                
SendClientMessage(playerid, COLOR_WHITE, "Elkezdtйl dolgozni.");
                
SetPlayerCheckpoint(playerid, 90.4303,-303.9684,1.6293, 1.0);
                new 
rand1 = random(sizeof(random_csomag_obj));
                new 
rand2 = random(sizeof(random_csomag_obj));
                
csomag_obj1[playerid] = CreatePlayerObject(playerid, 2891, random_csomag_obj[rand1][0], random_csomag_obj[rand1][1], random_csomag_obj[rand1][2], 0, 0, 0, 0.0);
                
csomag_obj2[playerid] = CreatePlayerObject(playerid, 2891, random_csomag_obj[rand2][0], random_csomag_obj[rand2][1], random_csomag_obj[rand2][2], 0, 0, 0, 0.0);
                new 
Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
                
GetObjectPos(csomag_obj1[playerid], x1, y1, z1);
                
GetObjectPos(csomag_obj2[playerid], x2, y2, z2);
                
csomag1text = CreatePlayer3DTextLabel(playerid, "Csomag", COLOR_YELLOW, x1, y1, z1, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1);
                
csomag2text = CreatePlayer3DTextLabel(playerid, "Csomag", COLOR_YELLOW, x2, y2, z2, 15.0, INVALID_PLAYER_ID, INVALID_VEHICLE_ID, 1);
                
csomagkihordo[playerid] = 2;
                                
// objects are made, but 3D text labels aren't.
            
}
        }
    }
    return 
1;
} 
PHP Code:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(
newkeys & KEY_WALK)      // BAL ALT player
    
{
        new 
csomagvehicle = GetClosestVehicle(playerid, 1.0);
        
GetClosestVehicle(playerid, 1.0);
        if(
GetVehicleModel(csomagvehicle) == 459)
        {
            if(
csomagkihordo[playerid] == 2)
            {
                if(
csomag_bepakolt[playerid] == 0)
                {
                    
csomag_bepakolt[playerid] = 1;
                    
SetPlayerSpecialAction(playerid, 0);
                    
RemovePlayerAttachedObject(playerid, 0);
                    
csomagkihordo[playerid] = 3;
                    return 
1;
                }
                if(
csomag_bepakolt[playerid] == 1)
                {
                    
csomag_bepakolt[playerid] = 2;
                    
SetPlayerSpecialAction(playerid, 0);
                    
RemovePlayerAttachedObject(playerid, 0);
                    
csomagkihordo[playerid] = 3;
                    return 
1;
                }
            }
        }
        if(
csomag_bepakolt[playerid] == 0)
        {
            new 
Float:x1, Float:y1, Float:z1, Float:x2, Float:y2, Float:z2;
            
GetObjectPos(csomag_obj1[playerid], x1, y1, z1);
            
GetObjectPos(csomag_obj2[playerid], x2, y2, z2);
            if(
IsPlayerInRangeOfPoint(playerid, 2.0, x1, y1, z1))
            {
                
DeletePlayer3DTextLabel(playerid, csomag1text);
                
DestroyPlayerObject(playerid, csomag_obj1[playerid]);
                
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
                
SetPlayerAttachedObject(playerid, 0, 1289, 5);
                return 
1;
            }
            if(
IsPlayerInRangeOfPoint(playerid, 2.0, x2, y2, z2))
            {
                
DeletePlayer3DTextLabel(playerid, csomag2text);
                
DestroyPlayerObject(playerid, csomag_obj2[playerid]);
                
SetPlayerSpecialAction(playerid, SPECIAL_ACTION_CARRY);
                
SetPlayerAttachedObject(playerid, 0, 1289, 5);
                return 
1;
            }
        }
    }
    return 
1;
} 
didn't work without the returns too.

Can you help me please?