XP when kill - 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: XP when kill (
/showthread.php?tid=383305)
XP when kill -
nicholas1 - 07.10.2012
I wonder how do you add xp when kill someone.Like,I am human and I kill zombie.How do I recieve the xp.I know how to set it like score.But,I want it like each kill you recieve randomy xp.For example,1st kill I get like 40 xp 2nd I get 14 and 3rd I will get like 20 see how it recieve differently.
Please help me I really need help with this.If you help me I will be so happy.
AW: XP when kill -
Nero_3D - 07.10.2012
You already got a kill variable, dont you? I will call it
gPlayerKills.
pawn Код:
// OnPlayerDeath
if(killerid != INVALID_PLAYER_ID) {
new
expGain,
kills = ++gPlayerKills[killerid]
;
if(kills == 1) { // for the first kill
expGain += 10; // 10 - 20 exp
}
if((kills % 5) == 0) { // for every fifth kill he gets bonus exp
expGain += kills; // 5 kills = 5 - 10 exp | 10 kills = 10 - 20 exp | 15 kills = 15 - 30 exp
}
if(reason < 16) {
expGain += 10; // melee kill = 10 - 20 exp
} else {
expGain += 5; // range kill = 5 - 10 exp
}
expGain += random(expGain); // random that he could get the double exp
}
That were my toughts, add what you want
Re: XP when kill -
nicholas1 - 07.10.2012
How do I put it in.This what I have for onplayerdeath.I remove my check player have weapon crap ban them.I remove that so now its just blank like this.
public OnPlayerDeath(playerid, killerid, reason)
{
return 1;
}
So,how do I add the stuff you put to mines.Can you put it how I add it on here together?
AW: XP when kill -
Nero_3D - 07.10.2012
Just in the middle...
pawn Код:
stock
gPlayerKills[MAX_PLAYERS]
;
pawn Код:
public OnPlayerDeath(playerid, killerid, reason) {
if(killerid != INVALID_PLAYER_ID) {
new
expGain,
kills = ++gPlayerKills[killerid]
;
if(kills == 1) { // for the first kill
expGain += 10; // 10 - 20 exp
}
if((kills % 5) == 0) { // for every fifth kill he gets bonus exp
expGain += kills; // 5 kills = 5 - 10 exp | 10 kills = 10 - 20 exp | 15 kills = 15 - 30 exp
}
if(reason < 16) {
expGain += 10; // melee kill = 10 - 20 exp
} else {
expGain += 5; // range kill = 5 - 10 exp
}
expGain += random(expGain); // random that he could get the double exp
// use here the function to give the player his exp
}
return true;
}
Re: XP when kill -
nicholas1 - 08.10.2012
I keep getting errors for kills = ++gPlayerKills[killerid] I will post type of errors later.
Re: XP when kill -
zSuYaNw - 08.10.2012
Check is player connected preventing Crash.
Re: XP when kill -
Kitten - 08.10.2012
pawn Код:
new xp[MAX_PLAYERS];
public OnPlayerDeath(playerid,killerid,reason)
{
xp[killerid] += 10;
return 1;
}
Re: XP when kill -
zSuYaNw - 08.10.2012
PHP код:
new xp[MAX_PLAYERS];
public OnPlayerDeath(playerid,killerid,reason)
{
// OnPlayerConnect check's is player connected,
// preventing Crash when use "-1"
// Exemple: xp[-1] ++; crash.
if(IsPlayerConnected(killerid)){
xp[killerid] ++;
}
return 1;
}
Re: XP when kill -
nicholas1 - 08.10.2012
Thanks Kitten and Garfield.A Kitten for your's how can I make the script have different xp randomly for each kill like you did in your server?
Re: XP when kill -
Kitten - 08.10.2012
pawn Код:
new xp[MAX_PLAYERS];
public OnPlayerDeath(playerid,killerid,reason)
{
switch(random(2))
{
case 0: xp[killerid] += 10;
case 1: xp[killerid] += 20;
}
return 1;
}