SA-MP Forums Archive
open gate with command - 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: open gate with command (/showthread.php?tid=254252)



open gate with command - ColdIce - 09.05.2011

Hello, I have admin area waaaaayyy up in the sky and a road that leads up there! I was wondering...How do I create a gate at the bottom and the top that opens only for admins??


Re: open gate with command - Marco_Valentine - 10.05.2011

new name;

ongamemodeinit
name = CreateObject(OBJECTID, x, y, z);

Onplayercommandtext
if(strcmp(cmd,"/open", true) == 0)
{
if(IsPlayerAdmin(playerid)){
MoveObject (name, x, y, z, speed);
return 1;
}

if(strcmp(cmd,"/close", true) == 0)
{
if(IsPlayerAdmin(playerid)){
MoveObject (name, x, y, z, speed);
return 1;
}

__
name is the name of the gate, name it anything you like.

under ongamemodeinit, paste where your object is being created.

onplayercommandtext is where your commands are use change the x,y,z to where you want it to move. and speed to how fast, i suggest 3-5 for the speed.

you must be logged into the /rcon to use the command


Re: open gate with command - ColdIce - 10.05.2011

So I just make a new pawno, put those things where they belong, and nothing else? Do I need to include streamer or sum?


Re: open gate with command - Mean - 10.05.2011

You don't need to open new PWN file, put this in your existing one, that "ongamemodeinit" means "under OnGameModeInit". Get it?


Re: open gate with command - ColdIce - 10.05.2011

Quote:

// This is a comment
// uncomment the line below if you want to write a filterscript
//#define FILTERSCRIPT

#include <a_samp>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" Blank Filterscript by your name here");
print("--------------------------------------\n");
return 1;
}

public OnFilterScriptExit()
{
return 1;
}

#else

main()
{
print("\n----------------------------------");
print(" Blank Gamemode by your name here");
print("----------------------------------\n");
}

#endif

public OnGameModeInit()
{
AdminGate = CreateObject(11319, -71.9565, 2704.5583, 61.5172);
}

public OnGameModeExit()
{
return 1;
}

public OnPlayerRequestClass(playerid, classid)
{
SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
return 1;
}

public OnPlayerConnect(playerid)
{
return 1;
}

public OnPlayerDisconnect(playerid, reason)
{
return 1;
}

public OnPlayerSpawn(playerid)
{
return 1;
}

public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}

public OnVehicleSpawn(vehicleid)
{
return 1;
}

public OnVehicleDeath(vehicleid, killerid)
{
return 1;
}

public OnPlayerText(playerid, text[])
{
return 1;
}

Onplayercommandtext
if(strcmp(cmd,"/open", true) == 0)
{
if(IsPlayerAdmin(playerid)){
MoveObject (AdminGate, -71.9565, 2704.5583, 61.5172, 3);
return 1;
}

if(strcmp(cmd,"/close", true) == 0)
{
if(IsPlayerAdmin(playerid)){
MoveObject (AdminGate, -71.9565, 2704.5583, 61.5172, 3);
return 1;
}

public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
return 1;
}

public OnPlayerExitVehicle(playerid, vehicleid)
{
return 1;
}

public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}

public OnPlayerEnterCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveCheckpoint(playerid)
{
return 1;
}

public OnPlayerEnterRaceCheckpoint(playerid)
{
return 1;
}

public OnPlayerLeaveRaceCheckpoint(playerid)
{
return 1;
}

public OnRconCommand(cmd[])
{
return 1;
}

public OnPlayerRequestSpawn(playerid)
{
return 1;
}

public OnObjectMoved(objectid)
{
return 1;
}

public OnPlayerObjectMoved(playerid, objectid)
{
return 1;
}

public OnPlayerPickUpPickup(playerid, pickupid)
{
return 1;
}

public OnVehicleMod(playerid, vehicleid, componentid)
{
return 1;
}

public OnVehiclePaintjob(playerid, vehicleid, paintjobid)
{
return 1;
}

public OnVehicleRespray(playerid, vehicleid, color1, color2)
{
return 1;
}

public OnPlayerSelectedMenuRow(playerid, row)
{
return 1;
}

public OnPlayerExitedMenu(playerid)
{
return 1;
}

public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid)
{
return 1;
}

public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}

public OnRconLoginAttempt(ip[], password[], success)
{
return 1;
}

public OnPlayerUpdate(playerid)
{
return 1;
}

public OnPlayerStreamIn(playerid, forplayerid)
{
return 1;
}

public OnPlayerStreamOut(playerid, forplayerid)
{
return 1;
}

public OnVehicleStreamIn(vehicleid, forplayerid)
{
return 1;
}

public OnVehicleStreamOut(vehicleid, forplayerid)
{
return 1;
}

public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
return 1;
}

public OnPlayerClickPlayer(playerid, clickedplayerid, source)
{
return 1;
}

Please correct this...I get 7 errors I suck so bad at this


Re: open gate with command - ColdIce - 10.05.2011

Someone?


Re: open gate with command - Marco_Valentine - 10.05.2011

Quote:

#include <a_samp>
new AdminGate;

public OnFilterScriptInit()
{
AdminGate = CreateObject(11319, -71.9565, 2704.5583, 61.5172, 0.0000, 0.0000, 0.0000);
}


public OnFilterScriptExit()
{

}


public OnPlayerConnect(playerid)
{
return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}


public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{

if(strcmp(cmdtext,"/open", true) == 0) {
if(IsPlayerAdmin(playerid)) {
if(IsPlayerInRangeOfPoint(playerid, 5.0, -71.9565, 2704.5583, 61.5172)) {
MoveObject (AdminGate, -71.9565, 2704.5583, 61.5172, 3);
}
}
return 1;
}

if(strcmp(cmdtext,"/close", true) == 0) {
if(IsPlayerAdmin(playerid)) {
if(IsPlayerInRangeOfPoint(playerid, 5.0, -71.9565, 2704.5583, 61.5172)) {
MoveObject (AdminGate, -71.9565, 2704.5583, 61.5172, 3);
}
}
return 1;
}

return 0;
}
That SHOULD work as a filterscript. just paste it all in and compile, BUT you haven't set co-ords to move your gate anywhere


Re: open gate with command - ColdIce - 10.05.2011

I knew there was more! How on earth do I do that?


Re: open gate with command - Marco_Valentine - 10.05.2011

move the gate?
Well you go on MTA open up the map where you made the gate, move the gate to where you want it to move on your command, save it. copy the position and put that in /open


Re: open gate with command - ColdIce - 12.05.2011

Quote:

#include <a_samp>
new AdminGate;

public OnFilterScriptInit()
{
AdminGate = CreateObject(987, -547.9476, -1570.6149, 6.6705);
}


public OnFilterScriptExit()
{

}


public OnPlayerConnect(playerid)
{
return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
return 1;
}


public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}


public OnPlayerStateChange(playerid, newstate, oldstate)
{
return 1;
}


public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
return 1;
}


public OnPlayerCommandText(playerid, cmdtext[])
{

if(strcmp(cmdtext,"/open", true) == 0) {
if(IsPlayerAdmin(playerid)) {
if(IsPlayerInRangeOfPoint(playerid, 5.0, -547.9476, -1570.6149, 6.6705)) {
MoveObject (AdminGate, -547.9476, -1570.6149, 11.4117, 3);
}
}
return 1;
}

if(strcmp(cmdtext,"/close", true) == 0) {
if(IsPlayerAdmin(playerid)) {
if(IsPlayerInRangeOfPoint(playerid, 5.0, -547.9476, -1570.6149, 11.4117)) {
MoveObject (AdminGate, -547.9476, -1570.6149, 6.6987, 3);
}
}
return 1;
}

return 0;
}

I did this and uploaded it, it created that object in the right place, and I moved the gate up and put that co-ord in the script as u can see, but nothing happens when I do /open or /close :/ Do u see anything wrong in that script?? Please help