SA-MP Forums Archive
What's wrong - 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: What's wrong (/showthread.php?tid=385878)



What's wrong - Yako - 18.10.2012

Hello, I making housing system. And I have a problem.

I want to make thing that player could enter the house when pressed Enter.

Here's my code:
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
for(new i = 0; i < sizeof(hInfo); i++)
{
if (IsPlayerInRangeOfPoint(playerid, 1.5,hInfo[i][enPos][0], hInfo[i][enPos][1], hInfo[i][enPos][2]))
{
if (PRESSED(KEY_SECONDARY_ATTACK))
{
SetPlayerInterior(playerid,hInfo[i][Interior]);
SetPlayerPos(playerid, hInfo[i][exPos][0], hInfo[i][exPos][1], hInfo[i][exPos][2]);
}
}
else
{
SendClientMessage(playerid, COLOR_RED, "You are not standing at any house!");
}
}
return 1;
}
And the problem is that, when I press Enter, I getting a lot of messages:
Код:
You are not standing at any house!
What I doing wrong?


AW: What's wrong - BiosMarcel - 18.10.2012

PHP код:
public OnPlayerKeyStateChange(playeridnewkeysoldkeys)
{
    for(new 
0sizeof(hInfo); i++)
    {
        if(
IsPlayerInRangeOfPoint(playerid1.5,hInfo[i][enPos][0], hInfo[i][enPos][1], hInfo[i][enPos][2]))
        {
            if(
PRESSED(KEY_SECONDARY_ATTACK))
            {
                
SetPlayerInterior(playerid,hInfo[i][Interior]);
                
SetPlayerPos(playeridhInfo[i][exPos][0], hInfo[i][exPos][1], hInfo[i][exPos][2]);
            }
        }
        else
        {
            
SendClientMessage(playeridCOLOR_RED"You are not standing at any house!");
        }
    }
    return 
1;




Re: What's wrong - Yako - 18.10.2012

Same thing:



Re: What's wrong - RedJohn - 18.10.2012

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) 
{ 
    for(new i = 0; i < sizeof(hInfo); i++) 
    { 
        if(IsPlayerInRangeOfPoint(playerid, 10,hInfo[i][enPos][0], hInfo[i][enPos][1], hInfo[i][enPos][2])) 
        { 
            if(PRESSED(KEY_SECONDARY_ATTACK)) 
            { 
                SetPlayerInterior(playerid,hInfo[i][Interior]); 
                SetPlayerPos(playerid, hInfo[i][exPos][0], hInfo[i][exPos][1], hInfo[i][exPos][2]); 
            } 
        } 
        else 
        { 
            SendClientMessage(playerid, COLOR_RED, "You are not standing at any house!"); 
        } 
    } 
    return 1; 
}



Re: What's wrong - Yako - 18.10.2012

Did you changed anything?


Re: What's wrong - RedJohn - 18.10.2012

if(IsPlayerInRangeOfPoint(playerid, 1.5,

to

if(IsPlayerInRangeOfPoint(playerid, 10,

1.5 is small as hell.


Re: What's wrong - Yako - 18.10.2012

But I getting the messages still


Re: What's wrong - Kirollos - 18.10.2012

Quote:
Originally Posted by RedJohn
Посмотреть сообщение
if(IsPlayerInRangeOfPoint(playerid, 1.5,

to

if(IsPlayerInRangeOfPoint(playerid, 10,

1.5 is small as hell.
that's not the soloution.

he scripted the callback wrong.

EDIT:

try this:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(PRESSED(KEY_SECONDARY_ATTACK))
	{
	    for(new i = 0; i < sizeof(hInfo); i++)
	    {
	        if(IsPlayerInRangeOfPoint(playerid, 1.5,hInfo[i][enPos][0], hInfo[i][enPos][1], hInfo[i][enPos][2]))
	        {
	            SetPlayerInterior(playerid,hInfo[i][Interior]);
				SetPlayerPos(playerid, hInfo[i][exPos][0], hInfo[i][exPos][1], hInfo[i][exPos][2]);
				break;
	        }
	        else continue;
	    }
	}
	return 1;
}
it will not give any client messages, but will 99% work


Re: What's wrong - RedJohn - 18.10.2012

Quote:
Originally Posted by kirollos
Посмотреть сообщение
that's not the soloution.

he scripted the callback wrong.
Then you help him.


Re: What's wrong - Kirollos - 18.10.2012

Quote:
Originally Posted by kirollos
Посмотреть сообщение
that's not the soloution.

try this:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if(PRESSED(KEY_SECONDARY_ATTACK))
	{
	    for(new i = 0; i < sizeof(hInfo); i++)
	    {
	        if(IsPlayerInRangeOfPoint(playerid, 1.5,hInfo[i][enPos][0], hInfo[i][enPos][1], hInfo[i][enPos][2]))
	        {
	            SetPlayerInterior(playerid,hInfo[i][Interior]);
				SetPlayerPos(playerid, hInfo[i][exPos][0], hInfo[i][exPos][1], hInfo[i][exPos][2]);
				break;
	        }
	        else continue;
	    }
	}
	return 1;
}
it will not give any client messages, but will 99% work
look at my edited post