Player3DText not showing, object not getting attached
#1

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(playeridnewstateoldstate)
{
    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(playeridrandomcsomag[rand][0], randomcsomag[rand][1], randomcsomag[rand][2],3.0);
            }
            if(
csomag_bepakolt[playerid] == 0)
            {
                
SendClientMessage(playeridCOLOR_WHITE"Elkezdtйl dolgozni.");
                
SetPlayerCheckpoint(playerid90.4303,-303.9684,1.62931.0);
                new 
rand1 random(sizeof(random_csomag_obj));
                new 
rand2 random(sizeof(random_csomag_obj));
                
csomag_obj1[playerid] = CreatePlayerObject(playerid2891random_csomag_obj[rand1][0], random_csomag_obj[rand1][1], random_csomag_obj[rand1][2], 0000.0);
                
csomag_obj2[playerid] = CreatePlayerObject(playerid2891random_csomag_obj[rand2][0], random_csomag_obj[rand2][1], random_csomag_obj[rand2][2], 0000.0);
                new 
Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2;
                
GetObjectPos(csomag_obj1[playerid], x1y1z1);
                
GetObjectPos(csomag_obj2[playerid], x2y2z2);
                
csomag1text CreatePlayer3DTextLabel(playerid"Csomag"COLOR_YELLOWx1y1z115.0INVALID_PLAYER_IDINVALID_VEHICLE_ID1);
                
csomag2text CreatePlayer3DTextLabel(playerid"Csomag"COLOR_YELLOWx2y2z215.0INVALID_PLAYER_IDINVALID_VEHICLE_ID1);
                
csomagkihordo[playerid] = 2;
                                
// objects are made, but 3D text labels aren't.
            
}
        }
    }
    return 
1;

PHP Code:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    if(
newkeys KEY_WALK)      // BAL ALT player
    
{
        new 
csomagvehicle GetClosestVehicle(playerid1.0);
        
GetClosestVehicle(playerid1.0);
        if(
GetVehicleModel(csomagvehicle) == 459)
        {
            if(
csomagkihordo[playerid] == 2)
            {
                if(
csomag_bepakolt[playerid] == 0)
                {
                    
csomag_bepakolt[playerid] = 1;
                    
SetPlayerSpecialAction(playerid0);
                    
RemovePlayerAttachedObject(playerid0);
                    
csomagkihordo[playerid] = 3;
                    return 
1;
                }
                if(
csomag_bepakolt[playerid] == 1)
                {
                    
csomag_bepakolt[playerid] = 2;
                    
SetPlayerSpecialAction(playerid0);
                    
RemovePlayerAttachedObject(playerid0);
                    
csomagkihordo[playerid] = 3;
                    return 
1;
                }
            }
        }
        if(
csomag_bepakolt[playerid] == 0)
        {
            new 
Float:x1Float:y1Float:z1Float:x2Float:y2Float:z2;
            
GetObjectPos(csomag_obj1[playerid], x1y1z1);
            
GetObjectPos(csomag_obj2[playerid], x2y2z2);
            if(
IsPlayerInRangeOfPoint(playerid2.0x1y1z1))
            {
                
DeletePlayer3DTextLabel(playeridcsomag1text);
                
DestroyPlayerObject(playeridcsomag_obj1[playerid]);
                
SetPlayerSpecialAction(playeridSPECIAL_ACTION_CARRY);
                
SetPlayerAttachedObject(playerid012895);
                return 
1;
            }
            if(
IsPlayerInRangeOfPoint(playerid2.0x2y2z2))
            {
                
DeletePlayer3DTextLabel(playeridcsomag2text);
                
DestroyPlayerObject(playeridcsomag_obj2[playerid]);
                
SetPlayerSpecialAction(playeridSPECIAL_ACTION_CARRY);
                
SetPlayerAttachedObject(playerid012895);
                return 
1;
            }
        }
    }
    return 
1;

didn't work without the returns too.

Can you help me please?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)