Every 15 kills do something
#1

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

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

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?
Reply
#4

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

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
}
Reply
#6

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

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

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

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?
Reply
#10

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


Forum Jump:


Users browsing this thread: 1 Guest(s)