How to create a gates with command (and for admins only)?
#1

Guys, I need help.
I wanted to create a admin house so I want to create a gate with command what open only for admins (not RCON only).
And I wanted to create a gate with using command, but for everyone who know the command?
Thanks if helped me.
Reply
#2

Put this just under the #include
pawn Код:
#include <a_samp>

new admingate;
Now, put this in before return 1; in public OnGameModeInit, like so:
pawn Код:
public OnGameModeInit()
{
    SetGameModeText("Your Script");
    AddPlayerClass(0, 5.0, 5.0, 5.0, 269.1425, 0, 0, 0, 0, 0, 0);
    admingate = CreateObject(969, 0.0, 0.0, 3.0, 0.0, 0.0, 0.0);
    return 1;
}
Now, here comes the somewhat hard part. I'll use strcmp, the native PAWN command processor, forsake of experience of your scripting.

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/move", cmdtext, true, 10) == 0)
    {
        MoveObject(admingate, 0.0, 0.0, 10.0, 1.6);
        SendClientMessage(playerid, 0xFFFFFF, "The gate has magically moved!");
        return 1;
    }
    return 0;
}
To close, all you have to do is basically reverse it!

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/moveback", cmdtext, true, 10) == 0)
    {
        MoveObject(admingate, 0.0, 0.0, 3.0, 1.6);
        SendClientMessage(playerid, 0xFFFFFF, "The gate has magically moved back down!");
        return 1;
    }
    return 0;
}
And all you have to do is change the coordinates!

NOTE:THIS COMMAND IS FOR EVERYONE.
(Rep please, lol)
Reply
#3

Quote:
Originally Posted by Stuntkillas
Посмотреть сообщение
Put this just under the #include
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/move", cmdtext, true, 10) == 0)
    {
        MoveObject(admingate, 0.0, 0.0, 10.0, 1.6);
        SendClientMessage(playerid, 0xFFFFFF, "The gate has magically moved!");
        return 1;
    }
    return 0;
}
To close, all you have to do is basically reverse it!

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/moveback", cmdtext, true, 10) == 0)
    {
        MoveObject(admingate, 0.0, 0.0, 3.0, 1.6);
        SendClientMessage(playerid, 0xFFFFFF, "The gate has magically moved back down!");
        return 1;
    }
    return 0;
}
And all you have to do is change the coordinates!
(Rep please, lol)
lol asking for rep xD anyway:


pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/move", cmdtext, true, 10) == 0)
    {
                if(IsPlayerAdmin(playerid))you forgot this but @ igor_andrusenko: it's depends on your admin system
               {
        MoveObject(admingate, 0.0, 0.0, 10.0, 1.6);
        SendClientMessage(playerid, 0xFFFFFF, "The gate has magically moved!");
        }
                else SendClientMessage(playerid,COLOR,"You aren'
t rcon admin !");
    }

    if (strcmp("
/moveback", cmdtext, true, 10) == 0)
    {
                if(IsPlayerAdmin(playerid))//same
                {
        MoveObject(admingate, 0.0, 0.0, 3.0, 1.6);
        SendClientMessage(playerid, 0xFFFFFF, "
The gate has magically moved back down!");
        }
                else SendClientMessage(playerid,COLOR,"
You aren't rcon admin !");
    }
    return 1;//i think it'
s 1
}
Reply
#4

ok, thanks guys.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)