Am i doing it right? [Got little errors]
#1

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.
Reply
#2

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;
}
Reply
#3

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);
Reply
#4

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.
Reply
#5

ooh, thank you both

And thanks mionee for the link.
Reply
#6

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;

Reply
#7

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!
Reply
#8

But what if he is not hacking ?
Reply
#9

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;
}
Reply
#10

I just asked if it'll work properly..

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


Forum Jump:


Users browsing this thread: 1 Guest(s)