How to make this Rcon Admin only
#1

With my /goto command ive made it so if you say the command and your not logged into rcon,
it says you are not an administrator, and if ur logged into rcon, the command works,
But because my /setcash is diffrent format im not so sure,
Heres my code? How do i make it, If you say /givecash it shows usage,
If you do /givecash [id] it again shows usage,
But if you do /givecash [id] [amount] It says, You are not an Administrator,
So what would i add onto this so it checks if player is logged into rcon,
And if he is, It lets him use the command,
But if hes not it says You are not an Administrator,

pawn Код:
dcmd_setcash(playerid, params[])
{
    new
        giveplayerid,
        amount;
    if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname] [amount]");
    else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
    else
    {
      ResetPlayerMoney(playerid);
        GivePlayerMoney(giveplayerid, amount);
        new name[MAX_PLAYER_NAME], string[48];
    GetPlayerName(playerid, name, sizeof(name));
    format(string, sizeof(string), "Admin %s has set your cash to %d", name, amount);
    SendClientMessage(giveplayerid, 0xFFFF00AA, string);
    }
    return 1;
}
Reply
#2

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

where abouts on my code wud i put tht
Reply
#4

After dcmd_setcash(playerid, params[])...
Reply
#5

pawn Код:
dcmd_setcash(playerid, params[])
{
  if(IsPlayerAdmin(playerid))
  {
    // player is logged in as RCON-admin.
  }
  else
  {
    // player isn't logged in as RCON-admin.
  }
  return 1;
}
Reply
#6

Код:
dcmd_setcash(playerid, params[])
{
	new
		giveplayerid,
		amount;
  if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid,color,"You must be admin to use this command");
	if (sscanf(params, "ud", giveplayerid, amount)) SendClientMessage(playerid, 0xFF0000AA, "Usage: /givecash [playerid/partname] [amount]");
	else if (giveplayerid == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000AA, "Player not found");
	else
	{
	  ResetPlayerMoney(playerid);
		GivePlayerMoney(giveplayerid, amount);
		new name[MAX_PLAYER_NAME], string[48];
  	GetPlayerName(playerid, name, sizeof(name));
  	format(string, sizeof(string), "Admin %s has set your cash to %d", name, amount);
  	SendClientMessage(giveplayerid, 0xFFFF00AA, string);
	}
	return 1;
}
Is much less work..
Reply
#7

What Don answered was right.
Reply
#8

Im using Don's as a template for future cmds and this, ect
Only i change IsPlayerAdmin to my new system i using
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)