SA-MP Forums Archive
Hopeless with this script help me please . - 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: Hopeless with this script help me please . (/showthread.php?tid=180244)



Hopeless with this script help me please . - Scriptissue - 30.09.2010

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;




Re: Hopeless with this script help me please . - Stefan_Toretto - 30.09.2010

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...


Re: Hopeless with this script help me please . - [MWR]Blood - 30.09.2010

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;
}



Re: Hopeless with this script help me please . - [XST]O_x - 30.09.2010

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.


Re: Hopeless with this script help me please . - [SVRPG]Falcon - 30.09.2010

Nvm, already posted.


Re: Hopeless with this script help me please . - Scriptissue - 30.09.2010

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


Re: Hopeless with this script help me please . - Ash. - 30.09.2010

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



Re: Hopeless with this script help me please . - Scriptissue - 30.09.2010

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;




Re: Hopeless with this script help me please . - mmrk - 30.09.2010

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;
}