key pressed
#1

Hey,
i have a problem. Everytime I press FIRE, it goes only through the first if.

Code:
new iMaterial[][Material] = {
    {657, -1609.61829, -2692.89697, 47.30786, "Baum \n 'Schlagen' zum abbauen"},
    {747, -1627.54919, -2705.54858, 47.59386, "Stein \n 'Schlagen' zum abbauen"}
};
Code:
	
else if(PRESSED(KEY_FIRE))
	{
		if(GetPlayerVehicleID(playerid) == 0)
 		{
			for(new i=0; i<sizeof(iMaterial); i++)
			{
				if(!IsPlayerInRangeOfPoint(playerid, 2, iMaterial[i][m_x], iMaterial[i][m_y], iMaterial[i][m_z]))continue;
				if(GetObjectModel(iMaterial[i][modelid] == 657))
				{
		 			if(GetPlayerWeapon(playerid) == 4)
				 	{
			 			TextDrawShowForPlayer(playerid, Holz[playerid]);
					 	SetTimerEx("KaputtMaterial", 1500, false, "i", playerid);
			 		  	PlayerInfo[playerid][pHolz] += 5;
				 	}
				}
			 	else if(GetObjectModel(iMaterial[i][modelid] == 747))
			 	{
					if(GetPlayerWeapon(playerid) == 4)
					{
						TextDrawShowForPlayer(playerid, Stein[playerid]);
					 	SetTimerEx("KaputtMaterial", 1500, false, "i", playerid);
					 	PlayerInfo[playerid][pStein] += 5;
				 	}
				}
 			}
 		}
	}
Reply
#2

What are you trying to do?
Reply
#3

When you are near an object and have a knife, you'll get wood or stone. It depends on which object you stand.
Reply
#4

here:

PHP Code:
else if (PRESSED(KEY_FIRE))
{
    if (!
GetPlayerVehicleID(playerid))
    {
        new 
objectweaponid GetPlayerWeapon(playerid), i;
        for(; 
sizeof iMateriali++)
        {
            if (!
IsPlayerInRangeOfPoint(playerid2iMaterial[i][m_x], iMaterial[i][m_y], iMaterial[i][m_z])) continue;
            
object GetObjectModel(iMaterial[i][modelid]);
            switch (object)
            {
                case 
657:
                {
                    if (
weaponid == 4)
                    {
                        
TextDrawShowForPlayer(playeridHolz[playerid]);
                        
SetTimerEx("KaputtMaterial"1500false"i"playerid);
                        
PlayerInfo[playerid][pHolz] += 5;
                        return 
1;
                    }
                }
                case 
747:
                {
                    if (
weaponid == 4)
                    {
                        
TextDrawShowForPlayer(playeridStein[playerid]);
                        
SetTimerEx("KaputtMaterial"1500false"i"playerid);
                        
PlayerInfo[playerid][pStein] += 5;
                        return 
1;
                    }
                }
            }
        }
    }

Reply
#5

Quote:
Originally Posted by xMoBi
View Post
here:

PHP Code:
else if (PRESSED(KEY_FIRE))
{
    if (!
GetPlayerVehicleID(playerid))
    {
        new 
objectweaponid GetPlayerWeapon(playerid), i;
        for(; 
sizeof iMateriali++)
        {
            if (!
IsPlayerInRangeOfPoint(playerid2iMaterial[i][m_x], iMaterial[i][m_y], iMaterial[i][m_z])) continue;
            
object GetObjectModel(iMaterial[i][modelid]);
            switch (object)
            {
                case 
657:
                {
                    if (
weaponid == 4)
                    {
                        
TextDrawShowForPlayer(playeridHolz[playerid]);
                        
SetTimerEx("KaputtMaterial"1500false"i"playerid);
                        
PlayerInfo[playerid][pHolz] += 5;
                        return 
1;
                    }
                }
                case 
747:
                {
                    if (
weaponid == 4)
                    {
                        
TextDrawShowForPlayer(playeridStein[playerid]);
                        
SetTimerEx("KaputtMaterial"1500false"i"playerid);
                        
PlayerInfo[playerid][pStein] += 5;
                        return 
1;
                    }
                }
            }
        }
    }

it doesn't work. I used printf to see which point didn't go.
At
Code:
object = GetObjectModel(iMaterial[i][modelid]);
			switch (object)
			{
				case 657:
				{
					if (weaponid == 4)
					{
						TextDrawShowForPlayer(playerid, Holz[playerid]);
						SetTimerEx("KaputtMaterial", 1500, false, "i", playerid);
						PlayerInfo[playerid][pHolz] += 5;
						return 1;
					}
				}
				case 747:
				{
					if (weaponid == 4)
					{
						TextDrawShowForPlayer(playerid, Stein[playerid]);
						SetTimerEx("KaputtMaterial", 1500, false, "i", playerid);
						PlayerInfo[playerid][pStein] += 5;
						return 1;
					}
				}
			}
it didn't work
Reply
#6

I fixed it.
This line was fault.

Code:
object = GetObjectModel(iMaterial[i][modelid]);
The fix is:
Code:
object = iMaterial[i][modelid];
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)