What's wrong
#1

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?
Reply
#2

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;

Reply
#3

Same thing:
Reply
#4

Код:
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; 
}
Reply
#5

Did you changed anything?
Reply
#6

if(IsPlayerInRangeOfPoint(playerid, 1.5,

to

if(IsPlayerInRangeOfPoint(playerid, 10,

1.5 is small as hell.
Reply
#7

But I getting the messages still
Reply
#8

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
Reply
#9

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

he scripted the callback wrong.
Then you help him.
Reply
#10

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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)