Anti-Team-Kill
#1

Hey guys,
Is there some sort of anti team kill function? I know theres one in the SetPlayerTeam & GetPlayerTeam function, but that doesnt work correct. I setted the team of me & my friend to 0, and still was able to kill him, but he couldnt kill me. So is there any better function for this?

Also, how would i get a random number between 2 numbers?
Like:
RandomEx(500, 1000);
This would get a number between 500 & 1000. I know i saw it somewhere around the forum, but i dont know exactly where.

~Wesley
Reply
#2

https://sampwiki.blast.hk/wiki/SetPlayerTeam
Setting a player's team automatically does the anti-team killing part.
Reply
#3

Quote:
Originally Posted by Wesley221
View Post
I know theres one in the SetPlayerTeam & GetPlayerTeam function, but that doesnt work correct. I setted the team of me & my friend to 0, and still was able to kill him, but he couldnt kill me.
Quote:
Originally Posted by Delux13
View Post
https://sampwiki.blast.hk/wiki/SetPlayerTeam
Setting a player's team automatically does the anti-team killing part.
Read above
Reply
#4

Use onplayershootplayer and use =

pawn Code:
#define RandomEx(%1, %2) ((%1 + %2) / 2)
May not work. I just thought about it being created like that.
Reply
#5

Quote:
Originally Posted by Lorenc_
View Post
Use onplayershootplayer and use =

pawn Code:
#define RandomEx(%1, %2) ((%1 + %2) / 2)
May not work. I just thought about it being created like that.
Imma try the randomex in a min, and is it acurate with OPSP?
Edit:
The RandomEx doesnt work.
Code:
warning 236: unknown parameter in substitution (incorrect #define pattern)
This warning show's up
Reply
#6

pawn Code:
#define randomex(%1, %2) random(((%1 - %2)+ (%1)))
try this ^^
Reply
#7

Code:
warning 236: unknown parameter in substitution (incorrect #define pattern)
Also, is the OPSP anti-team kill accurate?
Reply
#8

Quote:
Originally Posted by Wesley221
View Post
Code:
warning 236: unknown parameter in substitution (incorrect #define pattern)
Also, is the OPSP anti-team kill accurate?
25 % of the time it'll loose it's track

--

Look inside the rBits thread, theres a function asked in there, it was a offtopic question but got answered.
Reply
#9

Thanks!
pawn Code:
#define RandomEx(%0,%1) \
    (random((%1) - (%0)) + (%0))
This did the trick

Also i got a new question, not related to team kills/randomex, but about saving my files.
Again its not saving the right way.
http://pastebin.com/nX3FHRT5
The first things are when you register. Then when you save your files (log out), it doesnt overwrite the existing lines, but just creates new lines with a value in it. How can i fix this?
pawn Code:
forward SaveStats(playerid);
public SaveStats(playerid) // CONTAINS BUGGING INFORMATION
{
    new INI:file = INI_Open(UserPath(playerid));
    INI_SetTag(file, "data");
    INI_WriteInt(file, "Money", PlayerInfo[playerid][pMoney]); printf("Saved money %s", GetName(playerid));
    INI_WriteInt(file, "Score", PlayerInfo[playerid][pScore]); printf("Saved score %s", GetName(playerid));
    INI_WriteInt(file, "Admin level", PlayerInfo[playerid][pAdmin]); printf("Saved admin level %s", GetName(playerid));
    INI_WriteInt(file, "Vip level", PlayerInfo[playerid][pVip]); printf("Saved vip level %s", GetName(playerid));
    INI_WriteInt(file, "Commands used", PlayerInfo[playerid][pCMD]); printf("Saved commands used %s", GetName(playerid));
    INI_SetTag(file, "kills");      // kills tag
    INI_WriteInt(file, "RKills", PlayerInfo[playerid][pRKills]); printf("Saved last round kills %s", GetName(playerid));
    INI_WriteInt(file, "RDeaths", PlayerInfo[playerid][pRDeaths]); printf("Saved last round deaths %s", GetName(playerid));
    INI_WriteInt(file, "RKD", PlayerInfo[playerid][pRKd]); printf("Saved last round kd %s", GetName(playerid));
    INI_WriteInt(file, "Kills", PlayerInfo[playerid][pKills]); printf("Saved total kills %s", GetName(playerid));
    INI_WriteInt(file, "Deaths", PlayerInfo[playerid][pDeaths]); printf("Saved total deaths %s", GetName(playerid));
    INI_WriteInt(file, "KD", PlayerInfo[playerid][pKd]); printf("Saved total kd %s", GetName(playerid));
    INI_SetTag(file, "weapons");        // weapons tag
    INI_WriteInt(file, "Weapon 0", WeaponInfo[playerid][pWeapon0]); printf("Saved Weaponinfo0 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 1", WeaponInfo[playerid][pWeapon1]); printf("Saved Weaponinfo1 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 2", WeaponInfo[playerid][pWeapon2]); printf("Saved Weaponinfo2 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 3", WeaponInfo[playerid][pWeapon3]); printf("Saved Weaponinfo3 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 4", WeaponInfo[playerid][pWeapon4]); printf("Saved Weaponinfo4 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 5", WeaponInfo[playerid][pWeapon5]); printf("Saved Weaponinfo5 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 6", WeaponInfo[playerid][pWeapon6]); printf("Saved Weaponinfo6 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 7", WeaponInfo[playerid][pWeapon7]); printf("Saved Weaponinfo7 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 8", WeaponInfo[playerid][pWeapon8]); printf("Saved Weaponinfo8 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 9", WeaponInfo[playerid][pWeapon9]); printf("Saved Weaponinfo9 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 10", WeaponInfo[playerid][pWeapon10]); printf("Saved Weaponinfo10 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 11", WeaponInfo[playerid][pWeapon11]); printf("Saved Weaponinfo11 %s", GetName(playerid));
    INI_SetTag(file, "weapons ammo");       // ammo tag
    INI_WriteInt(file, "Weapon 0 ammo", WeaponInfo[playerid][pAmmo0]); printf("Saved Weaponammo0 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 1 ammo", WeaponInfo[playerid][pAmmo1]); printf("Saved Weaponammo1 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 2 ammo", WeaponInfo[playerid][pAmmo2]); printf("Saved Weaponammo2 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 3 ammo", WeaponInfo[playerid][pAmmo3]); printf("Saved Weaponammo3 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 4 ammo", WeaponInfo[playerid][pAmmo4]); printf("Saved Weaponammo4 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 5 ammo", WeaponInfo[playerid][pAmmo5]); printf("Saved Weaponammo5 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 6 ammo", WeaponInfo[playerid][pAmmo6]); printf("Saved Weaponammo6 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 7 ammo", WeaponInfo[playerid][pAmmo7]); printf("Saved Weaponammo7 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 8 ammo", WeaponInfo[playerid][pAmmo8]); printf("Saved Weaponammo8 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 9 ammo", WeaponInfo[playerid][pAmmo9]); printf("Saved Weaponammo9 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 10 ammo", WeaponInfo[playerid][pAmmo10]); printf("Saved Weaponammo10 %s", GetName(playerid));
    INI_WriteInt(file, "Weapon 11 ammo", WeaponInfo[playerid][pAmmo11]); printf("Saved Weaponammo11 %s", GetName(playerid));
    INI_Close(file);
    return 1;
}
This gets called at OnPlayerDisconnect
As you can see the variables contain information, so that isnt the problem. It also has the INI_SetTag, and its all the same!
~Wesley
Reply
#10

http://forum.sa-mp.com/showthread.ph...ight=team+kill

maybe this will help ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)