SA-MP Forums Archive
Am i doing it right? [Got little errors] - 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: Am i doing it right? [Got little errors] (/showthread.php?tid=554099)



Am i doing it right? [Got little errors] - Glossy42O - 02.01.2015

I'm trying to make anti minigun[Detection]

And i got little errors, btw will it work right without those errors?!?

PHP код:
public OnPlayerDeath(playeridkilleridreason)
{
   if(
GetPlayerWeapon(killerid) == 38)
   {
     for(new 
i=0i<MAX_PLAYERSi++)
     {
       if(
IsPlayerAdmin(i))
       {
         
SendClientMessage(i, -1"{FF0000}%s has been reported automatically by the server[Reason: Minigun], Advice: Spec"killerid);
       }
       else
       {
         if(
IsPlayerConnected(killerid)) return SendClientMessage(i, -1"{FF0000}WARNING: %s HAS LEFT THE SERVER"killerid);
       }
    }
  }
  return 
1;

Код:
C:\Users\yan\Desktop\Scripting tests\filterscripts\antimini.pwn(22) : warning 202: number of arguments does not match definition
C:\Users\yan\Desktop\Scripting tests\filterscripts\antimini.pwn(26) : warning 202: number of arguments does not match definition
C:\Users\yan\Desktop\Scripting tests\filterscripts\antimini.pwn(30) : warning 217: loose indentation
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


3 Warnings.



Re: Am i doing it right? [Got little errors] - Dignity - 02.01.2015

You can't format strings like that.

https://sampwiki.blast.hk/wiki/Format

Also, use foreach for player loops.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPlayerWeapon(killerid) == 38)
    {
        foreach(new i: Player)
        {
            if(IsPlayerAdmin(i))
            {
                new string[110];
               
                format(string, sizeof(string), "{FF0000}%s has been reported automatically by the server[Reason: Minigun], Advice: Spec", killerid);
                SendClientMessage(i, -1, string);
            }
            else
            {
                if(IsPlayerConnected(killerid)) return SendClientMessage(i, -1, "{FF0000}WARNING: %s HAS LEFT THE SERVER", killerid);
            }
        }
    }
    return 1;
}



Re: Am i doing it right? [Got little errors] - N.K.Stallone - 02.01.2015

Quote:
Originally Posted by Mionee
Посмотреть сообщение
You can't format strings like that.

https://sampwiki.blast.hk/wiki/Format

Also, use foreach for player loops.

pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
    if(GetPlayerWeapon(killerid) == 38)
    {
        foreach(new i: Player)
        {
            if(IsPlayerAdmin(i))
            {
                new string[110];
               
                format(string, sizeof(string), "{FF0000}%s has been reported automatically by the server[Reason: Minigun], Advice: Spec", killerid);
                SendClientMessage(i, -1, string);
            }
            else
            {
                if(IsPlayerConnected(killerid)) return SendClientMessage(i, -1, "{FF0000}WARNING: %s HAS LEFT THE SERVER", killerid);
            }
        }
    }
    return 1;
}
Same goes for his other line

pawn Код:
SendClientMessage(i, -1, "{FF0000}WARNING: %s HAS LEFT THE SERVER", killerid);



Re: Am i doing it right? [Got little errors] - Dignity - 02.01.2015

Quote:
Originally Posted by bgtracker
Посмотреть сообщение
Same goes for his other line

pawn Код:
SendClientMessage(i, -1, "{FF0000}WARNING: %s HAS LEFT THE SERVER", killerid);
Oh thanks, I didn't even notice that one, lol. Like bgtracker said, you also have to format your other message using a string.


Re: Am i doing it right? [Got little errors] - Glossy42O - 02.01.2015

ooh, thank you both

And thanks mionee for the link.


Re: Am i doing it right? [Got little errors] - Glossy42O - 02.01.2015

1 more thing, will it work properly ?

PHP код:
public OnPlayerWeaponShot(playeridweaponidhittypehitidFloat:fXFloat:fYFloat:fZ)
{
  if(
GetPlayerWeapon(playerid) == 38)
  {
   foreach(new 
iPlayer)
   {
     if(
IsPlayerAdmin(i))
     {
        new 
string [128];
        
        
format(stringsizeof(string), "{FF0000}ATTENTION: The server has automatically reported %s for using minigun, He has to be spectated"playerid);
        
SendClientMessage(i, -1string);
     }
     else
     {
        new 
string [128];
        if(
IsPlayerConnected(playerid)) return format(stringsizeof(string), "{FF0000}ATTENTION: %s HAS LEFT THE SERVER!"playerid);
     }
   }
 }
 return 
1;




Re: Am i doing it right? [Got little errors] - Ryz - 02.01.2015

I don't understand why you added this part

pawn Код:
else
     {
        new string [128];

        if(IsPlayerConnected(playerid)) return format(string, sizeof(string), "{FF0000}ATTENTION: %s HAS LEFT THE SERVER!", playerid);
     }
you have added string %s for what? you have just added playerid!


Re: Am i doing it right? [Got little errors] - Glossy42O - 02.01.2015

But what if he is not hacking ?


Re: Am i doing it right? [Got little errors] - Ryz - 02.01.2015

pawn Код:
public OnPlayerWeaponShot(playerid, weaponid, hittype, hitid, Float:fX, Float:fY, Float:fZ)
{
  if(GetPlayerWeapon(playerid) == 38)
  {
     foreach(new i: Player)
     {
        if(IsPlayerAdmin(i))
        {
           if( i != playerid )
           {
              new name[MAX_PLAYER_NAME], string[128];
              GetPlayerName(playerid, name, sizeof(name));
              format(string, sizeof(string), "{FF0000}ATTENTION: The server has automatically reported %s for using minigun, He has to be spectated", name);
              SendClientMessage(i, -1, string);
           }
        }
     }
 }
 return 1;
}



Re: Am i doing it right? [Got little errors] - Glossy42O - 02.01.2015

I just asked if it'll work properly..

EDIT: mine works fine but, it shows the message like 9999 times everytime i shoot.