Gate Help {Need A Fix]
#1

Here Is The Code To A Gate That Will Open If/When You Press Enter Well It Should Open
Quote:

#include <a_samp>

new gate;
#define enter 16
new IsGateOpen;
public OnFilterScriptInit()
{
gate = CreateObject(971, -693.51, 965.70, 13.25, 0.00, 0.00, -90.00);
CreateObject(2886, -693.63, 960.74, 12.76, 0.00, 0.00, -90.00);
CreateObject(2886, -687.16, 971.93, 12.50, 0.00, 0.00, 0.00);
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (newkeys && enter)
{
new name[24];
GetPlayerName(playerid, name,sizeof(name));
if (strcmp(name, "Your name",true) == 0)
if(IsPlayerInRangeOfPoint(playerid, 4.0,-687.1597, 971.9300, 12.5045))
{
if (IsGateOpen == 0)
{
MoveObject(gate,-693.5065, 965.7040, 7.0233,0.90);
ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 4.0, 0, 0, 0, 0, 0);
IsGateOpen = 1;
return 1;
}
if (IsGateOpen == 1)
{
MoveObject(gate, -693.51, 965.70, 13.31,0.90);
ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 4.0, 0, 0, 0, 0, 0);
IsGateOpen = 0;
return 1;
}
}
}
else if (newkeys && enter)
{
new name[24];
GetPlayerName(playerid, name,sizeof(name));
if (strcmp(name, "Your name",true) == 0)
if(IsPlayerInRangeOfPoint(playerid, 4.0,-693.6265, 960.7364, 12.7582))
{
if (IsGateOpen == 0)
{
MoveObject(gate,-693.5065, 965.7040, 7.0233,0.90);
ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 4.0, 0, 0, 0, 0, 0);
IsGateOpen = 1;
return 1;
}
if (IsGateOpen == 1)
{
MoveObject(gate, -693.51, 965.70, 13.31,0.90);
ApplyAnimation(playerid, "HEIST9", "Use_SwipeCard", 4.0, 0, 0, 0, 0, 0);
IsGateOpen = 0;
return 1;
}
}
}
return 1;
}

Reply
#2

if (strcmp(name, "Your name",true) == 0)

Meybe you need to change "Your name" to something else such as,

if (strcmp(name, "TheLazySloth", true) == 0)

Or you can just delete the if statement but you'll need to re-indent your code. Should be no problem.
Reply
#3

I know that its an old script for 0.3d and i need to get rif of Else if and replace it with if
but i have got it working in a way
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)