OnPlayerKeyStateChange
#1

[I]Hey guys!

I've got a problem in OnPlayerKeyStateChange callback.
pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        for(new i = 0; i <= MAX_BUSINESSES; i++) // now here's a loop through all businesses
        {
            if(IsPlayerInRangeOfPoint(playerid, 2.0, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2])) // and if player is in range of business entrance
            {
                if(vInfo[i][bought] == 0) SPMB(playerid, "Noredami pirkti versla rasykite~n~/pirktiversla [ID]");
                SetPlayerPos(playerid, vInfo[i][interior][0],vInfo[i][interior][1],vInfo[i][interior][2]);
                SetPlayerInterior(playerid, vInfo[i][inter]);
                TogglePlayerControllable(playerid, false);
                SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
                SetPlayerVirtualWorld(playerid, vInfo[i][ID]);
            }
            else if(IsPlayerInRangeOfPoint(playerid, 2.0, vInfo[i][interior][0],vInfo[i][interior][1],vInfo[i][interior][2])) // else if players is range of business exit
            {
                SetPlayerPos(playerid, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2]);
                SetPlayerInterior(playerid, 0);
                TogglePlayerControllable(playerid, false);
                SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
                SetPlayerVirtualWorld(playerid, 0);
            }
        } // !!!!! and when I want to enter the hospital or exit the hospital system doesn't react to this code below and when i press enter nothing happens.
        if(IsPlayerInRangeOfPoint(playerid, 2, 1590.9293,1762.1729,12.5320))
        {
            SetPlayerInterior(playerid, 3);
            SetPlayerPos(playerid,-204.5060,-1736.0486,675.7687);
            TogglePlayerControllable(playerid, false);
            SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
        }
        if(IsPlayerInRangeOfPoint(playerid, 2, -204.4959,-1735.3291,675.7687))
        {
            if(pInfo[playerid][gydos]) return SPMB(playerid, "~r~Kaip tu iseisi?~n~Tu juk gydaisi!");
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, 1590.9293,1762.1729,12.5320);
            TogglePlayerControllable(playerid, false);
            SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
        }
    }
    return 1;
[/i]

Hope you understood me.
+rep for helper
Reply
#2

Bump?
Reply
#3

Well, make sure that the coordinates from the isplayerinrangeofpoint are good. You can go to the entrance and type "/save" and then get the coordinates from the SA-MP/savedpoisitions.txt to be sure.

Also, you'd like to check the key using

pawn Код:
if(newkeys & KEY_SECONDARY_ATTACK)
https://sampwiki.blast.hk/wiki/OnPlayerK...heck_for_a_key
Reply
#4

It'd be nice if it works. But that's pretty weird, because I checked the coordinates and they are totally coorrect. Also, I tried using & instead of ==, but that didn't help me.
Reply
#5

I don't really see any other problem beside the coordinates. I tried to go to the coordinates: 1590.9293,1762.1729,12.5320 and it is inside a hospital in las venturas. And by inside i mean that you fall down.

Try replacing them with 1582.5271,1761.8899,10.8203 wich are the coordinates of the entrance in the hospital.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        for(new i = 0; i <= MAX_BUSINESSES; i++) // now here's a loop through all businesses
        {
            if(IsPlayerInRangeOfPoint(playerid, 2.0, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2])) // and if player is in range of business entrance
            {
                if(vInfo[i][bought] == 0) SPMB(playerid, "Noredami pirkti versla rasykite~n~/pirktiversla [ID]");
                SetPlayerPos(playerid, vInfo[i][interior][0],vInfo[i][interior][1],vInfo[i][interior][2]);
                SetPlayerInterior(playerid, vInfo[i][inter]);
                TogglePlayerControllable(playerid, false);
                SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
                SetPlayerVirtualWorld(playerid, vInfo[i][ID]);
            }
            else if(IsPlayerInRangeOfPoint(playerid, 2.0, vInfo[i][interior][0],vInfo[i][interior][1],vInfo[i][interior][2])) // else if players is range of business exit
            {
                SetPlayerPos(playerid, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2]);
                SetPlayerInterior(playerid, 0);
                TogglePlayerControllable(playerid, false);
                SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
                SetPlayerVirtualWorld(playerid, 0);
            }
        } // !!!!! and when I want to enter the hospital or exit the hospital system doesn't react to this code below and when i press enter nothing happens.
        if(IsPlayerInRangeOfPoint(playerid, 2, 1582.5271,1761.8899,10.8203))
        {
            SetPlayerInterior(playerid, 3);
            SetPlayerPos(playerid,-204.5060,-1736.0486,675.7687);
            TogglePlayerControllable(playerid, false);
            SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
        }
        if(IsPlayerInRangeOfPoint(playerid, 2, -204.4959,-1735.3291,675.7687))
        {
            if(pInfo[playerid][gydos]) return SPMB(playerid, "~r~Kaip tu iseisi?~n~Tu juk gydaisi!");
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, 1582.5271,1761.8899,10.8203);
            TogglePlayerControllable(playerid, false);
            SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
        }
    }
    return 1;
}
Also i hope that you have mapped an interior at the coords -204.4959,-1735.3291,675.7687 because when i go there, there's nothing, so you'll fall down.
Reply
#6

Quote:
Originally Posted by Koala818
Посмотреть сообщение
I don't really see any other problem beside the coordinates. I tried to go to the coordinates: 1590.9293,1762.1729,12.5320 and it is inside a hospital in las venturas. And by inside i mean that you fall down.

Try replacing them with 1582.5271,1761.8899,10.8203 wich are the coordinates of the entrance in the hospital.

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys == KEY_SECONDARY_ATTACK)
    {
        for(new i = 0; i <= MAX_BUSINESSES; i++) // now here's a loop through all businesses
        {
            if(IsPlayerInRangeOfPoint(playerid, 2.0, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2])) // and if player is in range of business entrance
            {
                if(vInfo[i][bought] == 0) SPMB(playerid, "Noredami pirkti versla rasykite~n~/pirktiversla [ID]");
                SetPlayerPos(playerid, vInfo[i][interior][0],vInfo[i][interior][1],vInfo[i][interior][2]);
                SetPlayerInterior(playerid, vInfo[i][inter]);
                TogglePlayerControllable(playerid, false);
                SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
                SetPlayerVirtualWorld(playerid, vInfo[i][ID]);
            }
            else if(IsPlayerInRangeOfPoint(playerid, 2.0, vInfo[i][interior][0],vInfo[i][interior][1],vInfo[i][interior][2])) // else if players is range of business exit
            {
                SetPlayerPos(playerid, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2]);
                SetPlayerInterior(playerid, 0);
                TogglePlayerControllable(playerid, false);
                SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
                SetPlayerVirtualWorld(playerid, 0);
            }
        } // !!!!! and when I want to enter the hospital or exit the hospital system doesn't react to this code below and when i press enter nothing happens.
        if(IsPlayerInRangeOfPoint(playerid, 2, 1582.5271,1761.8899,10.8203))
        {
            SetPlayerInterior(playerid, 3);
            SetPlayerPos(playerid,-204.5060,-1736.0486,675.7687);
            TogglePlayerControllable(playerid, false);
            SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
        }
        if(IsPlayerInRangeOfPoint(playerid, 2, -204.4959,-1735.3291,675.7687))
        {
            if(pInfo[playerid][gydos]) return SPMB(playerid, "~r~Kaip tu iseisi?~n~Tu juk gydaisi!");
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, 1582.5271,1761.8899,10.8203);
            TogglePlayerControllable(playerid, false);
            SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
        }
    }
    return 1;
}
Also i hope that you have mapped an interior at the coords -204.4959,-1735.3291,675.7687 because when i go there, there's nothing, so you'll fall down.
Damn man, this thing really gets crazy. I did what you said, but it still doesn't work ((((
Reply
#7

Oh... Silly me. Just what i noticed that you didn't put else. So bassically you are telleporting inside the hospital and back outside. Try this:

pawn Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
    if(newkeys & KEY_SECONDARY_ATTACK)
    {
        for(new i = 0; i <= MAX_BUSINESSES; i++) // now here's a loop through all businesses
        {
            if(IsPlayerInRangeOfPoint(playerid, 2.0, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2])) // and if player is in range of business entrance
            {
                if(vInfo[i][bought] == 0) SPMB(playerid, "Noredami pirkti versla rasykite~n~/pirktiversla [ID]");
                SetPlayerPos(playerid, vInfo[i][interior][0],vInfo[i][interior][1],vInfo[i][interior][2]);
                SetPlayerInterior(playerid, vInfo[i][inter]);
                TogglePlayerControllable(playerid, false);
                SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
                SetPlayerVirtualWorld(playerid, vInfo[i][ID]);
            }
            else if(IsPlayerInRangeOfPoint(playerid, 2.0, vInfo[i][interior][0],vInfo[i][interior][1],vInfo[i][interior][2])) // else if players is range of business exit
            {
                SetPlayerPos(playerid, vInfo[i][exterior][0],vInfo[i][exterior][1],vInfo[i][exterior][2]);
                SetPlayerInterior(playerid, 0);
                TogglePlayerControllable(playerid, false);
                SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
                SetPlayerVirtualWorld(playerid, 0);
            }
        } // !!!!! and when I want to enter the hospital or exit the hospital system doesn't react to this code below and when i press enter nothing happens.
        if(IsPlayerInRangeOfPoint(playerid, 3, 1582.5271,1761.8899,10.8203))
        {
            SetPlayerInterior(playerid, 3);
            SetPlayerPos(playerid,-204.5060,-1736.0486,675.7687);
            TogglePlayerControllable(playerid, false);
            SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
        }
        else if(IsPlayerInRangeOfPoint(playerid, 3, -204.4959,-1735.3291,675.7687))
        {
            if(pInfo[playerid][gydos]) return SPMB(playerid, "~r~Kaip tu iseisi?~n~Tu juk gydaisi!");
            SetPlayerInterior(playerid, 0);
            SetPlayerPos(playerid, 1582.5271,1761.8899,10.8203);
            TogglePlayerControllable(playerid, false);
            SetTimerEx("FreezeTimer", 2000, false, "i", playerid);
        }
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)