SA-MP Forums Archive
well, i made so admin cmds - 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)
+--- Thread: well, i made so admin cmds (/showthread.php?tid=375704)



well, i made so admin cmds - Qaiis - 07.09.2012

an now when i tied them, idk where the error are or anything, but look:

Код:
CMD:setmod(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new str[128];
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setmod [playerid]");
   if(PlayerInfo[PID][pAdmin] == 1) return SendClientMessage(playerid,0xFF0000FF, "That person is already moderator!");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"Owner %s made %s moderator. (Level: 1)", Adminname, Playername);
   SendClientMessageToAll(0xFF0000C8, str);
   PlayerInfo[PID][pAdmin] = 1;
   SendClientMessage(PID, 0xFF000000,"You have been made an moderator!");
   return 1;
}
CMD:setgmod(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new str[128];
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setgmod [playerid]");
   if(PlayerInfo[PID][pAdmin] == 1) return SendClientMessage(playerid,0xFF0000FF, "That person is already global moderator!");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"Owner %s made %s Global Moderator. (Level: 2)", Adminname, Playername);
   SendClientMessageToAll(0xFF0000C8, str);
   PlayerInfo[PID][pAdmin] = 2;
   SendClientMessage(PID, 0xFF000000,"You have been made an Global Moderator!");
   return 1;
}
CMD:setadmin(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new str[128];
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setadmin [playerid]");
   if(PlayerInfo[PID][pAdmin] == 1) return SendClientMessage(playerid,0xFF0000FF, "That person is already admin!");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"Owner %s made %s admin. (Level: 3)", Adminname, Playername);
   SendClientMessageToAll(0xFF0000C8, str);
   PlayerInfo[PID][pAdmin] = 3;
   SendClientMessage(PID, 0xFF000000,"You have been made an admin!");
   return 1;
}
CMD:sethealth(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new amount;
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, amount, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /sethealth [playerid] [amount] [reason]");

   if(amount > 100) return SendClientMessage(playerid,0xFF0000FF,"Max 100!");//Available levels
   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s health have been sat to %s by Admin %s. Reason: %s", Playername, amount, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   SetPlayerHealth(PID, amount);
   SendClientMessage(PID, 0xFF000000,"An admin changed you health!");
   return 1;
}
CMD:setarmour(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 2) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new amount;
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, amount, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setarmour [playerid] [amount] [reason]");
   if(amount > 100) return SendClientMessage(playerid,0xFF0000FF,"Max 100!");//Available levels

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s armour have been sat to %s by Admin %s. Reason: %s", Playername, amount, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   SetPlayerArmour(PID, amount);
   SendClientMessage(PID, 0xFF000000,"An admin changed you armour!");
   return 1;
}
CMD:setmoney(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new amount;
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, amount, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setmoney [playerid] [amount] [reason]");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s moneys have been sat to %s by Admin %s. Reason: %s", Playername, amount, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   GivePlayerMoney(PID, amount);
   SendClientMessage(PID, 0xFF000000,"An admin changed you money!");
   return 1;
}
CMD:setskin(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new amount;
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, amount, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setskin [playerid] [amount] [reason]");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s skin have been sat to %s by Admin %s. Reason: %s", Playername, amount, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   SetPlayerSkin(PID, amount);
   SendClientMessage(PID, 0xFF000000,"An admin changed you skin!");
   return 1;
}
CMD:setkills(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new amount;
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, amount, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setkills [playerid] [amount] [reason]");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s kills have been sat to %s by Admin %s. Reason: %s", Playername, amount, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   SetPlayerScore(PID, amount);
   SendClientMessage(PID, 0xFF000000,"An admin changed your kills!");
   return 1;
}
CMD:resetkills(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /resetkills [playerid] [reason]");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s kills have been reseted by Admin %s. Reason: %s", Playername, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   SetPlayerScore(PID, 0);
   PlayerInfo[PID][pKills] = 0;
   SendClientMessage(PID, 0xFF000000,"An admin reseted your kills!");
   return 1;
}
CMD:resetdeaths(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /resetdeaths [playerid] [reason]");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s deaths have been reseted by Admin %s. Reason: %s", Playername, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   PlayerInfo[PID][pDeaths] = 0;
   SendClientMessage(PID, 0xFF000000,"An admin reseted your deaths!");
   return 1;
}
CMD:resetstats(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 4 ) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /resetdeaths [playerid] [reason]");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s account have been reseted by Admin %s. Reason: %s", Playername, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   PlayerInfo[PID][pDeaths] = 0;
   PlayerInfo[PID][pKills] = 0;
   PlayerInfo[PID][pCash] = 0;
   PlayerInfo[PID][pMuted] = 0;
   PlayerInfo[PID][pAdmin] = 0;
   SetPlayerArmour(PID, 0);
   SetPlayerHealth(PID, 100);
   SendClientMessage(PID, 0xFF000000,"An admin reseted your account!");
   return 1;
}
CMD:setcolor(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new color;
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, color, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setcolor [playerid] [color] [reason]");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s color have been changed (hex: %s) by Admin %s. Reason: %s", Playername, color, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   SetPlayerColor(PID, color);
   SendClientMessage(PID, 0xFF000000,"An admin changed your color!");
   return 1;
}
CMD:givejet(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /givejet [playerid] [reason]");

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"%s got a jetpack spawned by Admin %s. Reason: %s", Playername, Adminname, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   SetPlayerSpecialAction(PID,SPECIAL_ACTION_USEJETPACK);
   SendClientMessage(PID, 0xFF000000,"An admin gave you a jetpack!");
   return 1;
}
CMD:jetpack(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 1) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   SetPlayerSpecialAction(playerid,SPECIAL_ACTION_USEJETPACK);
   SendClientMessage(playerid, 0xFF000000,"Spawned an jetack!");
   return 1;
}
CMD:givewep(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 3) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new reason[64];
   new str[128];
   new amount;
   new ammo;
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(sscanf(params, "s[64]", PID, amount, ammo, reason)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /givewep [playerid] [weaponid] [ammo] [reason]");
   if(amount < 1 || amount >46) return SendClientMessage(playerid,0xFF0000FF,"Wrong ID!");//Available levels
   if(ammo > 350) return SendClientMessage(playerid,0xFF0000FF,"Max 350 ammo!");//Available levels

   if(!IsPlayerConnected(PID))
       return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"Admin %s gave %s a weapon (ID: %s with ammo %s). Reason: %s", Adminname, Playername, amount, ammo, reason);
   SendClientMessageToAll(0xFF0000C8, str);
   GivePlayerWeapon(PID, amount, ammo);
   SendClientMessage(PID, 0xFF000000,"An admin gave you a weapon!");
   return 1;
}
and i got this:



help? :X


Re: well, i made so admin cmds - MarkoN - 07.09.2012

pawn Код:
if(sscanf(params, "u", PID)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setgmod [playerid]");
and should be before getting a players name... if not it will cause bugs


Re: well, i made so admin cmds - Qaiis - 07.09.2012

what you mean?


Re: well, i made so admin cmds - MarkoN - 07.09.2012

You should first get the sscanf params and then get the players name, and it should be 'u' (PlayerName/ID), so it should be like :
pawn Код:
CMD:setgmod(playerid, params[])
{
   if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, 0x99333300, "You can't make your own commands smartass!");
   new PID;
   new str[128];
   new Playername[MAX_PLAYER_NAME], Adminname[MAX_PLAYER_NAME];
   
   if(sscanf(params, "u", PID)) return SendClientMessage(playerid, 0xFF0000C8, "USAGE: /setgmod [playerid]");

   GetPlayerName(playerid, Adminname, sizeof(Adminname));
   GetPlayerName(PID, Playername, sizeof(Playername));

   if(PlayerInfo[PID][pAdmin] == 1) return SendClientMessage(playerid,0xFF0000FF, "That person is already global moderator!");

   if(!IsPlayerConnected(PID)) return SendClientMessage(playerid, 0xFF0000C8, "Player is not Connected!");

   format(str,sizeof(str),"Owner %s made %s Global Moderator. (Level: 2)", Adminname, Playername);
   SendClientMessageToAll(0xFF0000C8, str);
   PlayerInfo[PID][pAdmin] = 2;
   SendClientMessage(PID, 0xFF000000,"You have been made an Global Moderator!");
   return 1;
}



Re: well, i made so admin cmds - Qaiis - 07.09.2012

That will remove the sscanf warning too or?


Re: well, i made so admin cmds - MarkoN - 07.09.2012

it should


Re: well, i made so admin cmds - Qaiis - 08.09.2012

NOw i got this :