Hopeless with this script help me please .
#1

I tired to allow this command only after a check if the player is an Admin, but it doesn't work, I can use it without being an Admin, plus if ID is wrong it doesn't show anything.

PHP код:
CMD:slap(playeridparams[])
{
 if (
IsPlayerAdmin(playerid))
    
 
SendClientMessage(playerid0xFF4646FF"You are not authorized to use that command !");
    new 
otherId;
  if(
sscanf(params"u"otherId)) return SendClientMessage(playerid0xFF4646FF"USAGE: /slap [ID/PartOfname]");
    if(
otherId != INVALID_PLAYER_ID)
    {
    new 
message[40];
              new 
Float:slxFloat:slyFloat:slz;
        
GetPlayerPos(otherIdslxslyslz);
        
SetPlayerPos(otherIdslxslyslz+5);
        
PlayerPlaySound(otherId1130slxslyslz+5);
format(messagesizeof(message), "(( You have been slapped by admin ! ))");
            
SendClientMessage(playerid0xFFFFFFAAmessage);
          }
       
    return 
1;

Reply
#2

IsPlayerAdmin is used for RCON admin maybe you had been logged as an RCON admin and you didn't know this... and now you think that everyone can use it...
Reply
#3

pawn Код:
CMD:slap(playerid, params[])
{
 if (!IsPlayerAdmin(playerid))
{
     
 SendClientMessage(playerid, 0xFF4646FF, "You are not authorized to use that command !");
}
else
{

    new otherId;
  if(sscanf(params, "u", otherId)) return SendClientMessage(playerid, 0xFF4646FF, "USAGE: /slap [ID/PartOfname]");
    if(otherId != INVALID_PLAYER_ID)
    {
    new message[40];
              new Float:slx, Float:sly, Float:slz;
        GetPlayerPos(otherId, slx, sly, slz);
        SetPlayerPos(otherId, slx, sly, slz+5);
        PlayerPlaySound(otherId, 1130, slx, sly, slz+5);
format(message, sizeof(message), "(( You have been slapped by admin ! ))");
            SendClientMessage(playerid, 0xFFFFFFAA, message);
          }

        }
    return 1;
}
Reply
#4

You're checking if the player is an admin, and then telling him that he can't use that command. (?)
Hopelessness indeed, lol.

pawn Код:
if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF4646FF, "You are not authorized to use that command !");

else
{
  new otherId;
  if(sscanf(params, "u", otherId)) return SendClientMessage(playerid, 0xFF4646FF, "USAGE: /slap [ID/PartOfname]");
   if(otherId != INVALID_PLAYER_ID)
   {
       new Float:slx, Float:sly, Float:slz;
       GetPlayerPos(otherId, slx, sly, slz);
       SetPlayerPos(otherId, slx, sly, slz+5);
       PlayerPlaySound(otherId, 1130, slx, sly, slz+5);
       SendClientMessage(playerid, 0xFFFFFFAA, "(( You have been slapped by admin ! ))");
}
Also, why formatting a string without any contents? Only plain text? You don't need to format for that, useless variable.
Reply
#5

Nvm, already posted.
Reply
#6

It works, but it doesn't show whether the player's ID is valid or invalid .
Reply
#7

pawn Код:
if(otherid == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR, "Invalid Player ID");
Reply
#8

Thanks a lot.
I was trying to make one more thing, which I could not do whatsoever.
I don't know how, it is annoying I tired over then 10 times still nothing works, when player get slapped by Admin I tried to give the player a message that will show to him who slapped him, but It doesn't work.
When he get's slapped it just shows what I wrote but doesn't give the name of the Admin.
PHP код:
CMD:slap(playeridparams[])
{
if(!
IsPlayerAdmin(playerid)) return SendClientMessage(playerid0xFF4646FF"You are not authorized to use that command !");
else
{
  new 
otherId;
  new 
sendername[MAX_PLAYER_NAME];
  new 
string[256];
  if(
sscanf(params"u"otherId)) return SendClientMessage(playerid0xAFAFAFAA"USAGE: /slap [ID/PartOfname]");
 if(
otherId == INVALID_PLAYER_ID) return SendClientMessage(playerid0xAFAFAFAA"Invalid Player ID");
   {
       new 
Float:slxFloat:slyFloat:slz;
       
GetPlayerPos(otherIdslxslyslz);
       
SetPlayerPos(otherIdslxslyslz+5);
       
PlayerPlaySound(otherId1130slxslyslz+5);
       
       
                
format(stringsizeof(string), "(( You have been slapped by admin %s ))"sendername );
                
SendClientMessageToAll(0xFFFFFFAAstring);
}
        }
    return 
1;

Reply
#9

pawn Код:
GetPlayerName(playeird, sendername, sizeof(sendername)); // This is for admin name
And you don't need to send ClientMessageToAll just do:
pawn Код:
SendClientMessage(otherId, 0xFFFFFFAA, string);
pawn Код:
CMD:slap(playerid, params[])
{
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFF4646FF, "You are not authorized to use that command !");
    new otherId, sendername[MAX_PLAYER_NAME], string[128];  
    if(sscanf(params, "u", otherId)) return SendClientMessage(playerid, 0xAFAFAFAA, "USAGE: /slap [ID/PartOfname]");
    if(otherId == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xAFAFAFAA, "Invalid Player ID");
    {
        new Float:slx, Float:sly, Float:slz;
        GetPlayerPos(otherId, slx, sly, slz);
        SetPlayerPos(otherId, slx, sly, slz+5);
        PlayerPlaySound(otherId, 1130, slx, sly, slz+5);
        GetPlayerName(playeird, sendername, sizeof(sendername)); // This is for admin name
        format(string, sizeof(string), "(( You have been slapped by admin %s ))", sendername );
        SendClientMessage(otherId, 0xFFFFFFAA, string);
    }
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)