problem with moving objects
#1

hello, how i could do this code working ?

i want to do if player pres num 4 open gates if it closed and close gates if it's opened, but i have an error

Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
	if (PRESSED(KEY_ANALOG_LEFT ))
	{
if(IsPlayerInRangeOfPoint(playerid, 5.0, 1587.9688,-1722.7001,1449.6000))//6carter
	{
    if(PlayerInfo[playerid][pJailAccess] < 1) return SCM(playerid, COLOR_RED,"You don't have a key.");
    {
		if(GetObjectPos(GATE6, 1587.9688,-1722.7001,1449.6000)) MoveObject(GATE6,1587.89941406,-1718.39941406,1448.59997559,2.0); SCM(playerid,0xFFFFFFFF,"closing!");
		if(GetObjectPos(GATE6, 1587.89941406,-1718.39941406,1448.59997559)) MoveObject(GATE6,1587.9688,-1722.7001,1449.6000,2.0); SCM(playerid,0xFFFFFFFF,"opening!");
    }
	

	}
    return 1;
}
Код:
(342) : error 035: argument type mismatch (argument 2)
(343) : error 035: argument type mismatch (argument 2)
Reply
#2

I had the exact same problem, some of the keys just wouldn't work for me, change the KEY_ANALOG_LEFT withe KEY_FIRE or KEY_HANDBRAKE.
Reply
#3

KEY_ANALOG_LEFT is not detectable in OnPlayerStateChange callback
Reply
#4

no, KEY_ANALOG_LEFT is working than i use it only for opening gates, it's not workiing than i want to do closing and opening with the same key, this code problem is these two lines, but i don't know how to fix it

Код:
		if(GetObjectPos(GATE6, 1587.9688,-1722.7001,1449.6000)) MoveObject(GATE6,1587.89941406,-1718.39941406,1448.59997559,2.0); SCM(playerid,0xFFFFFFFF,"closing!");
		if(GetObjectPos(GATE6, 1587.89941406,-1718.39941406,1448.59997559)) MoveObject(GATE6,1587.9688,-1722.7001,1449.6000,2.0); SCM(playerid,0xFFFFFFFF,"opening!");
Reply
#5

Ues

new NameGate
Reply
#6

This is not how GetObjectPos works. Just use a static variable. Under your
pawn Код:
if (PRESSED(KEY_ANALOG_LEFT ))
add:
pawn Код:
static bool:gateOpen;
then:
pawn Код:
if(gateOpen == false) // is closed, open it
{

}
else // is open, close it
{

}

gateStatus = !gateStatus; // invert status; 1 -> 0, 0 -> 1
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)