SA-MP Forums Archive
Every 15 kills do something - 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: Every 15 kills do something (/showthread.php?tid=186745)



Every 15 kills do something - admantis - 30.10.2010

Hello everybody, i would like a script that every 10 kills it will give me a Permisson, just like this

pawn Код:
public OnPlayerDeath(playerid,killerid)
{
      // Every 10 kills...
      SendClientMessage(playerid,COLOR_GREEN,"[SERVER]: You have won a permisson! Use it to drive hunters and hydras")
       PlayerInfo[killerid][pPermissons]++;
       return 1;
}
Thanks everybody if someboy help I will put him in credits


Re: Every 15 kills do something - Hiddos - 30.10.2010

I'm unsure but I thought something about this operator: %

pawn Код:
if(!(PlayerInfo[killerd][pKills] % 15))
{
  //Do something
}
This might fail, I have never used this code before.


Respuesta: Re: Every 15 kills do something - admantis - 30.10.2010

Quote:
Originally Posted by Hiddos
Посмотреть сообщение
I'm unsure but I thought something about this operator: %

pawn Код:
if(!(PlayerInfo[killerd][pKills] % 15))
{
  //Do something
}
This might fail, I have never used this code before.
What does that % sign mean?
Anybody else?


Re: Every 15 kills do something - <Weponz> - 30.10.2010

EDIT: Typos..

Top of script

new Kills[MAX_PLAYERS];
Код:
public OnPlayerDeath(playerid,killerid)
{
      Kills[killerid] ++;

      if(Kills[killerid] == 10)
      {
      SendClientMessage(playerid,COLOR_GREEN,"[SERVER]: You have won a permisson! Use it to drive hunters and hydras")
       PlayerInfo[playerid][pPermissons]++;
       }
       return 1;
}
*New Code*

Not Tested..Should work..


Re: Every 15 kills do something - Cameltoe - 30.10.2010

Something like this?
pawn Код:
if(PlayerInfo[killerd][pKills] >= 15 && PlayerInfo[killerd][pKills] <= 20)
{
     // Do shit if kills is between 15 and 20
}
Though i would suggest you to have two variables:

pawn Код:
if(PlayerInfo[killerd][pKills] == 15 && PlayerInfo[killerd][pKillLevel] == 0)
{
     PlayerInfo[killerd][pKills] = 0;
     PlayerInfo[killerd][pKillLevel]++;
     // Do shit if kills == 15
}
else if(PlayerInfo[killerd][pKills] == 15 && PlayerInfo[killerd][pKillLevel] == 1)
{
     PlayerInfo[killerd][pKills] = 0;
     PlayerInfo[killerd][pKillLevel]++;
     // Do shit if kills == 30
}



Respuesta: Every 15 kills do something - admantis - 30.10.2010

@<Weponz>: It wont work because it will give permissons ONLY when you have 10 kills, but when you get more than 10 it won't do anymore

@Cameltoe: No, It's like a loop, every 10 kills it will give you a Permisson.


Re: Every 15 kills do something - CracK - 30.10.2010

% divides PlayerInfo[killerd][pKills] by 15 and gets the remainder
if(!(PlayerInfo[killerd][pKills] % 15)) is the same as: "If remainder is 0 then"


Re: Respuesta: Every 15 kills do something - Cameltoe - 30.10.2010

Quote:
Originally Posted by admantis
Посмотреть сообщение
@<Weponz>: It wont work because it will give permissons ONLY when you have 10 kills, but when you get more than 10 it won't do anymore

@Cameltoe: No, It's like a loop, every 10 kills it will give you a Permisson.
Quote:
Originally Posted by Cameltoe
Посмотреть сообщение
Something like this?
pawn Код:
if(PlayerInfo[killerd][pKills] >= 15 && PlayerInfo[killerd][pKills] <= 20)
{
     // Do shit if kills is between 15 and 20
}
Though i would suggest you to have two variables:

pawn Код:
if(PlayerInfo[killerd][pKills] == 15 && PlayerInfo[killerd][pKillLevel] == 0)
{
     PlayerInfo[killerd][pKills] = 0;
     PlayerInfo[killerd][pKillLevel]++;
     // Do shit if kills == 15
}
else if(PlayerInfo[killerd][pKills] == 15 && PlayerInfo[killerd][pKillLevel] == 1)
{
     PlayerInfo[killerd][pKills] = 0;
     PlayerInfo[killerd][pKillLevel]++;
     // Do shit if kills == 30
}
Re-Read.


Respuesta: Re: Every 15 kills do something - admantis - 30.10.2010

Quote:
Originally Posted by CracK
Посмотреть сообщение
% divides PlayerInfo[killerd][pKills] by 15 and gets the remainder
if(!(PlayerInfo[killerd][pKills] % 15)) is the same as: "If remainder is 0 then"
Then I doubt that will work, right?

@Cameltoe: then I would have to do it like 50 times what if a player has like 500 kills I had to do it that way , doing it over and over the code?


Re: Respuesta: Re: Every 15 kills do something - CracK - 30.10.2010

Quote:
Originally Posted by admantis
Посмотреть сообщение
Then I doubt that will work, right?
No doubt, it will work