admins only?
#1

how do i make this script for admins only...with no money oh and level 3 and above thx
Код:
//====================
// Created by ANtus [2010]
//====================
#include <a_samp>
//====================
new Menu:Menu;
new Menu:WepMenu;
new Menu:VehMenu;
new Menu:PlMenu;
//====================
#define COLOR_NARANCS 0xFF9900AA
//====================
public OnFilterScriptInit()
{
    Menu = CreateMenu("Menu", 1,20,120,150,40);
    AddMenuItem(Menu, 0, "Weapon Menu");
    AddMenuItem(Menu, 0, "Vehicle Menu");
    AddMenuItem(Menu, 0, "Player Menu");

    WepMenu = CreateMenu("Weapons", 1,20,120,150,40);
    AddMenuItem(WepMenu, 0, "Deagle ~g~$1500");
    AddMenuItem(WepMenu, 0, "Tec9 ~g~$2000");
    AddMenuItem(WepMenu, 0, "SMG ~g~$3000");
    AddMenuItem(WepMenu, 0, "AK47 ~g~$5000");
    AddMenuItem(WepMenu, 0, "M4A1 ~g~$6000");
    AddMenuItem(WepMenu, 0, "Sniper ~g~5000");
    
    AddMenuItem(WepMenu, 0, "B~r~ack");

    VehMenu = CreateMenu("Veh Menu", 1,20,120,150,40);
    AddMenuItem(VehMenu, 0, "Repair Vehicle ~g~$500");
    AddMenuItem(VehMenu, 0, "Black Vehicle ~g~$100");
    AddMenuItem(VehMenu, 0, "White Vehicle ~g~$100");
    AddMenuItem(VehMenu, 0, "Yellow Vehicle ~g~$10");
    
    AddMenuItem(VehMenu, 0, "B~r~ack");

    PlMenu = CreateMenu("AirPlanes", 1,20,120,150,40);
    AddMenuItem(PlMenu, 0, "Stunt ~g~$1500");
    AddMenuItem(PlMenu, 0, "Squallo ~g~$1200");
    AddMenuItem(PlMenu, 0, "Maverick ~g~$1500");
    
    AddMenuItem(PlMenu, 0, "B~r~ack");
    return 1;
}
//====================
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Menu", cmdtext, true, 10) == 0)
    {
      ShowMenuForPlayer(Menu,playerid);
      TogglePlayerControllable(playerid,false);
      return 1;
    }
    return 0;
}
//====================
public OnPlayerSelectedMenuRow(playerid, row)
{
  new Menu:CurrentMenu = GetPlayerMenu(playerid);
  if(CurrentMenu == Menu)
    {
  switch(row)
  {
    case 0:
    {
    	ShowMenuForPlayer(WepMenu, playerid);
    }
    case 1:
    {
      ShowMenuForPlayer(VehMenu, playerid);
    }
    case 2:
    {
      ShowMenuForPlayer(PlMenu, playerid);
    }
  }
  }
  if(CurrentMenu == WepMenu)
    {
  switch(row)
  {
    case 0:
    {
    GivePlayerMoney(playerid,1500);
    GivePlayerWeapon(playerid,24,100);
    GameTextForPlayer(playerid, "..::Desert Deagle::..",2000,5);
    TogglePlayerControllable(playerid,1);
    }
    case 1:
    {
    	GivePlayerMoney(playerid,2000);
    GivePlayerWeapon(playerid,32,100);
    GameTextForPlayer(playerid, "..::Tec9::..",2000,5);
    TogglePlayerControllable(playerid,1);
    }
    case 2:
    {
    	GivePlayerMoney(playerid,3000);
    GivePlayerWeapon(playerid,29,100);
    GameTextForPlayer(playerid, "..::SMG::..",2000,5);
    TogglePlayerControllable(playerid,1);
    }
    case 3:
    {
    	GivePlayerMoney(playerid,5000);
    GivePlayerWeapon(playerid,30,100);
    GameTextForPlayer(playerid, "..::AK47::..",2000,5);
    TogglePlayerControllable(playerid,1);
    }
    case 4:
    {
    	GivePlayerMoney(playerid,6000);
    GivePlayerWeapon(playerid,31,100);
    GameTextForPlayer(playerid, "..::M4A1::..",2000,5);
    TogglePlayerControllable(playerid,1);
    }
    case 5:
    {
    	GivePlayerMoney(playerid,1500);
    GivePlayerWeapon(playerid,34,100);
    GameTextForPlayer(playerid, "..::Sniper::..",2000,5);
    TogglePlayerControllable(playerid,1);
    }
    case 6:
    {
      ShowMenuForPlayer(Menu, playerid);
    }
  }
  }
  if(CurrentMenu == VehMenu)
    {
  switch(row)
  {
    case 0:
    {
    	GivePlayerMoney(playerid,-500);
		RepairVehicle(playerid);
		GameTextForPlayer(playerid, "Vehicle repaired!",2000,5);
    }
    case 1:
    {
    GivePlayerMoney(playerid,-100);
    	ChangeVehicleColor(playerid,random(0),random(0));
    	TogglePlayerControllable(playerid,1);
    }
    case 2:
    {
    	GivePlayerMoney(playerid,-100);
    	ChangeVehicleColor(playerid,random(1),random(1));
    	TogglePlayerControllable(playerid,1);
    }
    case 3:
    {
    	GivePlayerMoney(playerid,-100);
    	ChangeVehicleColor(playerid,random(6),random(6));
    	TogglePlayerControllable(playerid,1);
    }
    case 4:
    {
      ShowMenuForPlayer(Menu, playerid);
    }
  }
  }
  if(CurrentMenu == PlMenu)
    {
  switch(row)
  {
    case 0:
    {
    	new Float:X,Float:Y,Float:Z;
		GetPlayerPos(playerid, X,Y,Z);
		CreateVehicle(513, X,Y,Z, 0.0, 100, 100, 60000);
		HideMenuForPlayer(Menu, playerid);
		TogglePlayerControllable(playerid, true);
		GivePlayerMoney(playerid, -1500);
		new name[256];
		new string[256];
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "[INFO] %s got a Stunt-plane $1500.", name);
		SendClientMessageToAll(COLOR_NARANCS, string);
		TogglePlayerControllable(playerid,1);
    }
    case 1:
    {
    	new Float:X,Float:Y,Float:Z;
		GetPlayerPos(playerid, X,Y,Z);
		CreateVehicle(446, X,Y,Z, 0.0, 100, 100, 60000);
		HideMenuForPlayer(Menu, playerid);
		TogglePlayerControllable(playerid, true);
		GivePlayerMoney(playerid, -1200);
		new name[256];
		new string[256];
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "[INFO] %s got a Squallo for $1200.", name);
		SendClientMessageToAll(COLOR_NARANCS, string);
		TogglePlayerControllable(playerid,1);
    }
    case 2:
    {
    	new Float:X,Float:Y,Float:Z;
		GetPlayerPos(playerid, X,Y,Z);
		CreateVehicle(487, X,Y,Z, 0.0, 100, 100, 60000);
		HideMenuForPlayer(Menu, playerid);
		TogglePlayerControllable(playerid, true);
		GivePlayerMoney(playerid, -1500);
		new name[256];
		new string[256];
		GetPlayerName(playerid, name, sizeof(name));
		format(string, sizeof(string), "[INFO] %s got a Maverick for $1500.", name);
		SendClientMessageToAll(COLOR_NARANCS, string);
		TogglePlayerControllable(playerid,1);
    }
    case 3:
    {
      ShowMenuForPlayer(Menu, playerid);
    }
  }
  }
  return 1;
}
//====================
public OnPlayerExitedMenu(playerid)
{
  TogglePlayerControllable(playerid, true);
	return 1;
}
//====================
Reply
#2

To limit it only for RCON logged in admins, use IsPlayerAdmin function.
If you have filterscript/gamemode based admin function, then you have to use those features.

If you choose 2nd one, but haven't done one, use Dini or Dudb, depends which one is easier for you.
Reply
#3

Quote:
Originally Posted by newarvuti
To limit it only for RCON logged in admins, use IsPlayerAdmin function.
If you have filterscript/gamemode based admin function, then you have to use those features.

If you choose 2nd one, but haven't done one, use Dini or Dudb, depends which one is easier for you.
i dknt understand please walk me trew it at least gimme code ...im a noobie wish to be like 1 of u lol
Reply
#4

If you want, that only RCON admins can use it, use IsPlayerAdmin function.
Reply
#5

Quote:
Originally Posted by newarvuti
If you want, that only RCON admins can use it, use IsPlayerAdmin function.
how to use it? wot do i replace?
Reply
#6

Replace this part:
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/Menu", cmdtext, true, 10) == 0)
    {
      if(IsPlayerAdmin(playerid) == 1)
      {
        ShowMenuForPlayer(Menu,playerid);
        TogglePlayerControllable(playerid,false);
            }
            else
            {
              SendClientMessage(playerid, 0xFFFFFF00, "You are not an admin!");
              return 1;
            }
    }
    return 0;
}
Reply
#7

Either login as rcon admin or make a variable that loads on player connect either the player id admin or not
if u choosed to login as rcon admin, use the code above that newarvuti wrote for u else try to figure out how u would implement this one :

// Braintest:
Код:
new Admin[MAX_PLAYERS];
// onregister
Код:
dini_IntSet(cfile, "Admin", 0);
// On login
Код:
SetPlayerAdmin(playerid, dini_Int(cfile, "Admin"));
// SetPlayerAdmin function
Код:
stock SetPlayerAdmin(playerid,cash)
{
Admin[playerid] = cash;
return Admin[playerid];
}
// Sample cmd
Код:
if(!strcmp(cmdtext, "/admin", true, 8))
{
  if(GetPlayerAdmin(playerid) >= 1)
  {
		SendClientMessage(playerid, green, "Yes really! you are an admin :D");
  }
}
Reply
#8

can you do the same with vehicles? limit cars to admins only? ive seen it done , but how?
Reply
#9

yes
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(vehicleid == uradmincarid && Admin[playerid] >=1)return 1;
return 0;
}
change uradmincarid to whatever car id u want ^^ untested but i think it should work.
Reply
#10

Im A Noob scripter lol , started like last week =[ just working on a new server now, so i want to learn commands and bit by bit ,
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)