Button Activated Gates That Only Open For A Certain Player Name
#1

Hello,
For my server i am trying to create gates that will open when a SPECIFIC player presses the SECONDARY_FIRE key.

Ill use myself as an example to try and explain this. On the server i have my very own house and i have a gate to acces my driveway. What i want this gate to do is open when i press the SECONDARY_FIRE and it will only open for me. My username is Stuoyto, so the gate would only open if 'Stuoyto' presses not key not another player such as 'John'.

If anyone knows a code for this then i would greatly appreciate it.


Stuoyto
Reply
#2

https://sampwiki.blast.hk/wiki/MoveObject
Reply
#3

pawn Code:
if(strcmp(pName, "Stuoyto", 10, true) == 0)
{

}
You would have to make pName equal to the players name. As far as the button, look into SouthClaw's button script.
Reply
#4

pawn Code:
new IsGateOpen;



public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
   
    if (newkeys && SECONDARY_FIRE)
    {
        new name[24];
        GetPlayerName(playerid, name,sizeof(name));
        if (strcmp(name, "Your name",true) == 0)
        {
            if (IsGateOpen == 0)
            {
            //MoveObject(....); //when you want to open the gate
            IsGateOpen = 1;
            return 1;
            }
            if (IsGateOpen == 1)
            {
            //MoveObject(....); //when you want to close the gate
            IsGateOpen = 0;
            return 1;
            }
        }
    }
    return 1;
}
Reply
#5

Thanks alot Jakku that is exactly what i was looking for. If i can i will give you rep
Reply
#6

I have used the code and changed it to match my username. I have also added the co-ordinates of my gate when its open and closed. This is what my code looks like so far;

Code:
#include <a_samp>

new IsGateOpen;

//MY ADMIN HOUSE GATE===========================================================
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{

    if (newkeys && SECONDARY_FIRE)
    {
        new name[24];
        GetPlayerName(playerid, name,sizeof(name));
        if (strcmp(name, "stuoyto",true) == 0)
        {
            if (IsGateOpen == 0)
            {
            MoveObject(987, -2648.56, -220.47, -2.88,   0.00, 0.00, 180.00);
            IsGateOpen = 1;
            return 1;
            }
            if (IsGateOpen == 1)
            {
            MoveObject(987, -2648.56, -220.47, 3.32,   0.00, 0.00, 180.00);
            IsGateOpen = 0;
            return 1;
            }
        }
    }
    return 1;
}
I am not even sure if this is the correct way of setting out the co-ordinates (if not plaese tell me what to put in the 'MoveObject' brackets).
However, when i compile the program the following error occurs;

Quote:

C:\Users\Stuart\Desktop\SAMP STUFF\My Server\filterscripts\VIPGates.pwn(9) : error 017: undefined symbol "SECONDARY_FIRE"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase


1 Error.
How can i sort this error?



Stuoyto
Reply
#7

Secondary fire is the wrong thing to put for pressing a key, im not sure what it is but find out and replace "SECONDARY_FIRE" with the correct term.
Reply
#8

Quote:
Originally Posted by English-Conceptz
View Post
Secondary fire is the wrong thing to put for pressing a key, im not sure what it is but find out and replace "SECONDARY_FIRE" with the correct term.
You're right, I just copied the example and wrote the other lines.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)