Posts: 1,185
Threads: 72
Joined: Jan 2011
Reputation:
25
03-23-2011, 18:56
(This post was last modified: 03-23-2011, 19:20 by Tomsen1410.)
Hey,
ive got a Problem with my Mod. I wanna incluede custom Killstreaks. So here is the Function, which counts the Kills after Death:
PHP Code: KillCounter() { self endon("disconnect"); self endon("death");
wait 0.1; self.StartKills = self.pers["kills"]; self.Killstreak = 0; self thread setKillsToZero();
for(;;) { if(self.Killstreak != self.pers["kills"] - self.StartKills) {self.Killstreak = self.pers["kills"] - self.StartKills;} wait 0.1; } } setKillsToZero() { self endon("disconnect"); for(;;) { self waittill("death"); self.StartKills = self.pers["kills"]; self.Killstreak = 0; } }
But this Function is very buggy. The game laggs and when someone dies the game will freeze for some secs...
Anybody can help?
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
Code: for(;;)
{
self waittill("death");
self.StartKills = self.pers["kills"];
self.Killstreak = 0;
}
Inf. loop.. add wait .05;
Posts: 1,185
Threads: 72
Joined: Jan 2011
Reputation:
25
(03-23-2011, 19:29)Pozzuh Wrote: Code: for(;;)
{
self waittill("death");
self.StartKills = self.pers["kills"];
self.Killstreak = 0;
}
Inf. loop.. add wait .05;
there is a selfwaittill. Thats enough.
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
03-23-2011, 19:45
(This post was last modified: 03-23-2011, 19:45 by Pozzuh.)
You're right. Wasn't paying attention. Sorry.
btw. Isn't there a variable for killstreak already?
Posts: 1,185
Threads: 72
Joined: Jan 2011
Reputation:
25
(03-23-2011, 19:45)Pozzuh Wrote: You're right. Wasn't paying attention. Sorry.
btw. Isn't there a variable for killstreak already?
no, that works correctly. only the lagg and freeze issue is ther prob.
Posts: 5,135
Threads: 241
Joined: Nov 2010
Reputation:
100
self.pers["cur_kill_streak"]
You can use that for your custom killstreaks.
Posts: 1,185
Threads: 72
Joined: Jan 2011
Reputation:
25
(03-23-2011, 20:13)Pozzuh Wrote: self.pers["cur_kill_streak"]
You can use that for your custom killstreaks.
And how does this work?^^
Posts: 3,704
Threads: 147
Joined: Jan 2011
Reputation:
119
03-23-2011, 21:30
(This post was last modified: 03-23-2011, 21:34 by Nekochan.)
Use my code,
PHP Code: onplayerspawned() { self.killcount = self.kills; self.numberofstreaks = 0; self.usingstreak = 0; for(;;) { self waittill("spawned_player"); self setClientDvar("cg_weaponCycleDelay", 0); self thread streaks(); self maps\mp\gametypes\_class::setKillstreaks( "none", "none", "none" ); } } streaks() { self endon("death"); self.startscore = self.kills; self.killcount = 0; while(1) { if(self.killcount != self.kills - self.startscore){ self.killcount = self.kills - self.startscore; switch(self.killcount) { case 5: self KillstreakNotify(HARDPOINT TYPE, "Press [{+actionslot 4}] for blalblab"); break; //ETC } } wait 0.0000000000001; // OMFG ANTI BUG LIKE } }
KillstreakNotify( streakName, txt) { self endon("disconnect"); self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "Killstreak: "+self.killcount, txt, "", (0,0,1) ); self maps\mp\gametypes\_hardpoints::giveKillstreak( streakname , streakname, true ); self iprintln(self.name + " got killstreak with " + self.killcount + " kills!");
wait 1; }
C++/Obj-Cdeveloper. Neko engine wip
Steam: Click
Posts: 1,185
Threads: 72
Joined: Jan 2011
Reputation:
25
03-23-2011, 22:03
(This post was last modified: 03-23-2011, 22:13 by Tomsen1410.)
(03-23-2011, 21:30)Se7en Wrote: Use my code,
PHP Code: onplayerspawned() { self.killcount = self.kills; self.numberofstreaks = 0; self.usingstreak = 0; for(;;) { self waittill("spawned_player"); self setClientDvar("cg_weaponCycleDelay", 0); self thread streaks(); self maps\mp\gametypes\_class::setKillstreaks( "none", "none", "none" ); } } streaks() { self endon("death"); self.startscore = self.kills; self.killcount = 0; while(1) { if(self.killcount != self.kills - self.startscore){ self.killcount = self.kills - self.startscore; switch(self.killcount) { case 5: self KillstreakNotify(HARDPOINT TYPE, "Press [{+actionslot 4}] for blalblab"); break; //ETC } } wait 0.0000000000001; // OMFG ANTI BUG LIKE } }
KillstreakNotify( streakName, txt) { self endon("disconnect"); self thread maps\mp\gametypes\_hud_message::oldNotifyMessage( "Killstreak: "+self.killcount, txt, "", (0,0,1) ); self maps\mp\gametypes\_hardpoints::giveKillstreak( streakname , streakname, true ); self iprintln(self.name + " got killstreak with " + self.killcount + " kills!");
wait 1; }
thx
i hope this isnt laggy than mine ^^
BTW: I like the OMFG ANTI BUG LIKE comment^^
Posts: 993
Threads: 86
Joined: Feb 2011
Reputation:
49
cool i was about to post a thread on this xD but now it here ill just ask,
i would like to have custom killstreaks mixed with one's a have made," ie
on 3 kill's give morterstrike and on 5 kill's give minigun that shot's rpg's,
i also seen this code Code: if(self.pers["cur_kill_streak"] == 25)
{
self maps\mp\gametypes\_hardpoints::giveKillstreak("");
}
could that help?
arrrg im just really confused on how to get this to work
|