Buttons not working - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Buttons not working (
/showthread.php?tid=595307)
Buttons not working -
Alpha000 - 01.12.2015
When i go near LSPD button and press F nothing happens....here are my codes.
PHP Code:
public OnPlayerPressButton(playerid, buttonid)
{
// LSPD
if(buttonid == lspdcopsonly)
{
if(PlayerInfo[playerid][pLeader] == 1 || PlayerInfo[playerid][pLeader] == 2 || PlayerInfo[playerid][pFaction] == 1 || PlayerInfo[playerid][pFaction] == 2 || PlayerInfo[playerid][pFaction] == 5)
{
DoorOpen(playerid);
SetTimer("DoorClose", 4000, 0);
}
else
{
SendClientMessage(playerid, COLOR_GREY, " You're not a Cop / FBI!");
}
}
if(buttonid == lspdeveryone)
{
DoorOpen(playerid);
SetTimer("DoorClose", 3500, 0);
}
DoorOpen:
PHP Code:
forward DoorOpen(playerid);
public DoorOpen(playerid)
{
MoveDynamicObject(lspddoor1, 247.2763671875,72.536186218262,1002.640625, 3.5000);
MoveDynamicObject(lspddoor2, 244.0330657959,72.580932617188,1002.640625, 3.5000);
return 1;
}
LSPD Buttons:
PHP Code:
//LSPD Button
lspdcopsonly = CreateButton(244.90686035156, 72.328125, 1003.9609375, 3.0); // ONLYS ONLY
lspdeveryone = CreateButton(244.92, 73.42, 1004.27, 92.0); // People, ^^==LSPD
CreateDynamicObject(2886, 244.90686035156, 72.328125, 1003.9609375,0,0,3.0, 20002); //lspdcopsonly button
CreateDynamicObject(2886, 244.92, 73.42, 1004.27,0,0,92.0, 20002); //lspdeveryone button
lspddoor1 = CreateDynamicObject(1569, 246.35150146484, 72.547714233398, 1002.640625, 0.000000, 0.000000, 0.000000); //
lspddoor2 = CreateDynamicObject(1569, 245.03300476074, 72.568511962891, 1002.640625, 0.000000, 0.000000, 0.000000); //
It don't even show me this error:
Code:
You're not a Cop / FBI
Re: Buttons not working -
TwinkiDaBoss - 01.12.2015
You are complicating stuff too much.
PHP Code:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
new GateStatus;
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if (PRESSED(KEY_SECONDARY_ATTACK)) { //If button is F or Enter
if(IsPlayerInRangeOfPoint(playerid,3,247.2763671875,72.536186218262,1002.640625)) { //if they are near PD
if(GateStatus == 0) { //if gate wasnt moved so far aka its on its default values
SetTimer("DoorOpen", 3500, 0); //or whatever you use to open your gates/doors
SendClientMessage(playerid,COLOR_RED,"You have opened PD gates");
GateStatus = 1;
}
else if(GateStatus == 1) { //If the gate was moved previously, aka someone used F near it to open it
SetTimer("DoorClose", 3500, 0); //or whatever you use to close your gates/doors
SendClientMessage(playerid,COLOR_RED,"You have closed PD gates");
GateStatus = 0;
}
}
}
return 1;
}
Dont use yom_buttons, better make a textdraw instead and control it like that, or use the code above that Ive given you to have it simply with F or Enter button to open/close.