what's wrong with this code - 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 wrong with this code (
/showthread.php?tid=459625)
what's wrong with this code -
Strier - 24.08.2013
pawn Код:
public OnPlayerTakeDamage(playerid, issuerid, Float:amount, weaponid)
{
DMG[issuerid] += amount;
for(new i=0;i<MAX_PLAYERS;i++)
{
new Float:pos[3];
GetPlayerPos(i, pos[0], pos[1], pos[2]);
if(IsPlayerInRangeOfPoint(issuerid, 0.40, pos[0], pos[1], pos[2]) && pInfo[i][team] == pInfo[issuerid][team])
{
if(DMG[issuerid] > 30)
{
new Float:hp; hp = GetPlayerHealth(playerid, hp);
if(hp < 1)
{
new string[65];
format(string, sizeof(string), "[ASSIST KILL] You've helped your team to kill %s, You gain +1 kill and $5000", pInfo[playerid][pname]);
SendClientMessage(issuerid, 0xFF00FF, string);
pInfo[issuerid][kills]++;
SetPlayerMoney(issuerid, GetPlayerMoney(issuerid) +5000);
}
}
}
}
return 1;
}
this code compiles fine, but doesn't do anything, any reason?
By "doesn't do anything" i mean, the issuerid, doesn't get the message :/.
Re: what's wrong with this code -
Pottus - 24.08.2013
Your range of 0.40 is so low it will never activate also your array is wrong you need to keep track of damage of all players not dump it all into one variable you also need to keep track of time for example.
pawn Код:
enum DMGINFO
{
DMGPlayer[MAX_PLAYERS],
DMGTime[MAX_PLAYERS],
}
DMG[MAX_PLAYERS][DMGINFO]
So now what you do is check the time before adding damage if the time is greater than say 10 seconds it would reset how much damage you've done and set the damage amount to the damage you just did. Anyways you got a lot more problems than just a bad range the design is flawed.
Re: what's wrong with this code -
Strier - 24.08.2013
aha, thanks i'll test it out!