How to create a gates with command (and for admins only)? - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: How to create a gates with command (and for admins only)? (
/showthread.php?tid=273659)
How to create a gates with command (and for admins only)? -
igor_andrusenko - 02.08.2011
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.
Re: How to create a gates with command (and for admins only)? -
Ruffles. - 02.08.2011
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)
Re: How to create a gates with command (and for admins only)? -
Michael@Belgium - 02.08.2011
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
}
Re: How to create a gates with command (and for admins only)? -
igor_andrusenko - 02.08.2011
ok, thanks guys.