KEY_SECONDARY_ATTACK and /enter
#1

Dear guys,

I tried to write a script to let people enter houses and businesses using /enter or the KEY_SECONDARY_ATTACK key. Buy I don't know how to get it to work.

Could someone help me please?

I've tried to use:

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( newkeys == KEY_SECONDARY_ATTACK )
    {
       
    }

    return 1;
}
But I don't know how to implement it.


http://pastebin.com/Euw8PmSK

Thank you,
Michael
Reply
#2

You would do something like this:
pawn Код:
for(new idx=1; idx<MAX_BIZ; idx++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ])) // these are the coordinates from your business enum
            {
                    // set player position to the interior of the business and the rest      
            }
        }
So this code searches for the nearest business that the player is from.
Reply
#3

Quote:
Originally Posted by dominik523
Посмотреть сообщение
You would do something like this:
pawn Код:
for(new idx=1; idx<MAX_BIZ; idx++)
        {
            if(IsPlayerInRangeOfPoint(playerid, 2, BizInfo[idx][bX], BizInfo[idx][bY], BizInfo[idx][bZ])) // these are the coordinates from your business enum
            {
                    // set player position to the interior of the business and the rest      
            }
        }
So this code searches for the nearest business that the player is from.
There is another trick, you don't need to re-code it :P

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if( newkeys & KEY_SECONDARY_ATTACK )
        return OnPlayerCommandText(playerid, "/enter");

    return true;
}
Reply
#4

@pds2k12 very clever I must say. I would never think of something like that. Good work!
Reply
#5

Yahoooo!!! It's working! Thank you guys.
Reply
#6

Is there a way to use the same KEY_SECONDARY_ATTACK to exit?

I've tried this, but it does not work. I can enter. But not exit using the same key.

Quote:

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{


if( newkeys & KEY_SECONDARY_ATTACK ){
return OnPlayerCommandText(playerid, "/enter");

// return true;
}

if( newkeys & KEY_SECONDARY_ATTACK ){
return OnPlayerCommandText(playerid, "/exit");

// return true;
}

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)