SA-MP Forums Archive
What's the problem? - 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: What's the problem? (/showthread.php?tid=296013)



What's the problem? - Mr_Scripter - 09.11.2011

after when i got my server portforwarded i got my friend to test something we were testing but if i kill him 3 times my samp-server.exe (black box thing) closes automaticaly.. i got killing spree thing.. anyone know what's the problem?
pawn Code:
public OnPlayerDeath(playerid, killerid, reason) {
        new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
        #pragma unused string
        GetPlayerName(playerid, pname, sizeof(pname));
        KillingSpree[killerid] ++;
        KillingSpree[playerid] = 0;

        if(KillingSpree[killerid] == 3) {
         SendClientMessage(playerid,COLOR_ORANGE,"%s is on killing spree!");
        }
        return 1;
    }



Re: What's the problem? - CSSI - 09.11.2011

You must Use the format function
pawn Code:
if(KillingSpree[killerid] == 3) {
        GetPlayerName(killerid,pname,sizeof(pname));
        format(string,sizeof(string),"%s is on a killing spree",pname);
         SendClientMessageToAll(COLOR_ORANGE,string);

        }
Remove this #pragma unused string


Re: What's the problem? - Mr_Scripter - 09.11.2011

i removed the #pragma unused string Now it gives
pawn Code:
E:\GTA - San Andreas\Pawno Scripting\gamemodes\Script.pwn(373) : warning 204: symbol is assigned a value that is never used: "string"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Warning.



Re: What's the problem? - CSSI - 09.11.2011

did u add this Line ?
pawn Code:
SendClientMessageToAll(COLOR_ORANGE,string);



Re: What's the problem? - Mr_Scripter - 09.11.2011

here it is btw, String??
pawn Code:
public OnPlayerDeath(playerid, killerid, reason) {
        new pname[MAX_PLAYER_NAME], string[39 + MAX_PLAYER_NAME];
        GetPlayerName(playerid, pname, sizeof(pname));
        KillingSpree[killerid] ++;
        KillingSpree[playerid] = 0;

        if(KillingSpree[killerid] == 3) {
         SendClientMessage(playerid,COLOR_ORANGE,"%s is on killing spree!");
        }
        return 1;
    }



Re: What's the problem? - SmiT - 09.11.2011

You can't use sendclientmessage like that! As CSSI said, you should use format:

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new
        pname[ MAX_PLAYER_NAME ], string[ 39 + MAX_PLAYER_NAME ];
       
    GetPlayerName( playerid, pname, sizeof ( pname ) );
   
    KillingSpree[ killerid ] ++;
    KillingSpree[ playerid ] = 0;
   
    format ( string, sizeof ( string ), "%s is on killing spree!", pname );
   
    if ( KillingSpree[ killerid ] == 3 )
    {
        SendClientMessage( playerid, COLOR_ORANGE, string);
    }
    return true;
}



Re: What's the problem? - CSSI - 09.11.2011

pawn Code:
public OnPlayerDeath(playerid, killerid, reason) {
        KillingSpree[killerid] ++;
        KillingSpree[playerid] = 0;
         if(KillingSpree[killerid] == 3) {
         new pname[24],string[128];
          GetPlayerName(killerid, pname, sizeof(pname));
         format(string,sizeof(string),"%s is on a killing spree!",pname);
         SendClientMessageToAll(COLOR_ORANGE,string);
        }

        return 1;
    }



Re: What's the problem? - Stigg - 09.11.2011

Try:
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new pname[24],string[128];
    GetPlayerName(killerid, pname, sizeof(pname));
    KillingSpree[killerid] ++;
    KillingSpree[playerid] = 0;
    if(KillingSpree[killerid] == 3)
    {
        format(string,sizeof(string),"%s is on a killing spree with %d kills",pname,KillingSpree[killerid]);
        SendClientMessageToAll(COLOR_ORANGE,string);
    }
    if(KillingSpree[killerid] == 6)
    {
        format(string,sizeof(string),"%s is on a killing spree with %d kills",pname,KillingSpree[killerid]);
        SendClientMessageToAll(COLOR_ORANGE,string);
    }
    if(KillingSpree[killerid] == 9)
    {
        format(string,sizeof(string),"%s is on a killing spree with %d kills",pname,KillingSpree[killerid]);
        SendClientMessageToAll(COLOR_ORANGE,string);
    }
    if(KillingSpree[killerid] == 12)
    {
        //ect......
    }
    return 1;
}



Re: What's the problem? - Mr_Scripter - 09.11.2011

Thanks yall anyone know how can i make if someone kill a player with 3 kills get 1k etc?


Re: What's the problem? - Stigg - 09.11.2011

Quote:
Originally Posted by Mr_Scripter
View Post
Thanks yall anyone know how can i make if someone kill a player with 3 kills get 1k etc?
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
    new pname[24],string[128];
    GetPlayerName(killerid, pname, sizeof(pname));
    KillingSpree[killerid] ++;
    KillingSpree[playerid] = 0;
    if(KillingSpree[killerid] == 3)
    {
        format(string,sizeof(string),"%s is on a killing spree with %d kills",pname,KillingSpree[killerid]);
        SendClientMessageToAll(COLOR_ORANGE,string);
        GivePlayerMoney(killerid, 1000);
    }
    if(KillingSpree[killerid] == 6)
    {
        format(string,sizeof(string),"%s is on a killing spree with %d kills",pname,KillingSpree[killerid]);
        SendClientMessageToAll(COLOR_ORANGE,string);
        GivePlayerMoney(killerid, 1000);
    }
    if(KillingSpree[killerid] == 9)
    {
        format(string,sizeof(string),"%s is on a killing spree with %d kills",pname,KillingSpree[killerid]);
        SendClientMessageToAll(COLOR_ORANGE,string);
        GivePlayerMoney(killerid, 1000);
    }
    if(KillingSpree[killerid] == 12)
    {
        //ect......
    }
    return 1;
}