Need some tips in saving Specific weapon kills -
SpikY_ - 13.07.2015
Hi,
I was thinking to make a weapon stats for my server. i was confused how can i save the weapon kills i mean how can i save a specific weapon kills like :
Deagle kills : %d
m4 kills : %d
ak-47 kills : %d
Sawn off Shotgun kills : %d
( In MSGBOX dialog )
I WANT SOME TIPS THAT where should i create them all, OnPlayerDeath. If yes then how....?
Re: Need some tips in saving Specific weapon kills -
zSuYaNw - 13.07.2015
https://sampwiki.blast.hk/wiki/GetPlayerWeapon
Re: Need some tips in saving Specific weapon kills -
WilliamOordt - 13.07.2015
You could use GetPlayerWeapon(killerid) when the player dies and set that to a variable.
Re: Need some tips in saving Specific weapon kills -
SpikY_ - 13.07.2015
like this if i want to save the kills.
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPlayerWeapon(killerid) == 24) AccInfo[playerid][Deagle]++;
return 1;
}
Re: Need some tips in saving Specific weapon kills -
zSuYaNw - 13.07.2015
https://sampforum.blast.hk/showthread.php?tid=234691
Re: Need some tips in saving Specific weapon kills -
SpikY_ - 14.07.2015
Quote:
Originally Posted by zSuYaNw
|
I'm using lux admin system and i want to add this saving system in it.
See the codes i prepared to save specific weapon kills.
When i kill someone it counts to 1 then it doesn't increase if i kill someone.
here is the command from which we can see the specific weapon kills :
pawn Код:
if(strcmp(cmd, "/weapstats", true) == 0)
{
new string[128];
new player1;
new file[100];
if(!strlen(params)) player1 = playerid;
else player1 = strval(params);
if(IsPlayerConnected(player1))
{
new dialog[1000];
format(file,sizeof(file),"/eAdmin/Accounts/%s.sav",udb_encode(PlayerName2(player1)));
format(string, sizeof(string),"{72A6FF}Deagle: {FFFFFF}%d\n",AccInfo[player1][Deagle]);
strcat(dialog,string);
ShowPlayerDialog(playerid, 4178, DIALOG_STYLE_MSGBOX,"{FFFF00}eX-MM - {FFFFFF}Player's Weapon Statistics",dialog,"Close","");
} else
return SendClientMessage(playerid, red, "{FF0000}» Error: {BABABA}Player Not Connected.");
}
///other saving codessss
enum PlayerData
{
Registered
}
public OnPlayerConnect(playerid)
{
AccInfo[playerid][Deagle] = 0;
}
public OnPlayerDisconnect(playerid, reason)
{
AccInfo[playerid][Deagle] = 0;
}
SavePlayerStats(playerid)
{
dUserSetINT(PlayerName2(playerid)).("Deagle",AccInfo[playerid][Reactionwon]);
}
LoginPlayer(playerid)
{
AccInfo[playerid][Deagle] = (dUserINT(PlayerName2(playerid)).("Deagle"));
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(GetPlayerWeapon(killerid) == 24) AccInfo[playerid][Deagle]++;
return 1;
}
Re: Need some tips in saving Specific weapon kills -
SpikY_ - 14.07.2015
anyone please?
Re: Need some tips in saving Specific weapon kills -
karemmahmed22 - 14.07.2015
I'm not pro scripter but, maybe if you made a integer you retrive the kills in then ++ it, update the file again it will work
Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new kills;
kills == AccInfo[playerid][Deagle];
if(GetPlayerWeapon(killerid) == 24) kills++
AccInfo[playerid][Deagle] == kills
return 1;
}
Idk if it will work or no, i just typed this code from my mind, not a script or smth its just idea
Re: Need some tips in saving Specific weapon kills -
SpikY_ - 14.07.2015
These codes fucked my script. Getting like 100+ errors.
and i don't think it will work. bad codes
Re: Need some tips in saving Specific weapon kills -
Lordzy - 14.07.2015
You can create an array to store kills count for each weapon and then save them using file or database systems. I'm pasting a small snippet that I've created long time ago, I'm not sure if I've tested. I hadn't created any saving systems for this before since it was only for testing.
pawn Код:
#include <a_samp>
new
g_PlayerKills[MAX_PLAYERS][37];
public OnPlayerDeath(playerid, killerid, reason) {
if(killerid != INVALID_PLAYER_ID) {
g_PlayerKills[killerid][36]++;
if(reason >= 0 && reason <= 18)
g_PlayerKills[killerid][reason]++;
else if(reason >= 22 && reason <= 38)
g_PlayerKills[killerid][reason-3]++;
}
return 1;
}
public OnPlayerConnect(playerid) {
for(new i = 0; i< 37; i++)
g_PlayerKills[playerid][i] = 0;
return 1;
}
/*
playerid - The player to get the kill stats of.
to_playerid - The player to which kill stats of playerid is shown.
*/
stock ShowPlayerKillStats(playerid, to_playerid) {
new
temp_dString[1024],
temp_WName[32],
temp_PName[MAX_PLAYER_NAME];
GetPlayerName(playerid, temp_PName, sizeof(temp_PName));
format(temp_dString, sizeof(temp_dString), "%s (ID:%d) kill stats!\n\nTotal Kills : %d", temp_dPName, playerid, g_PlayerKills[playerid][36]);
for(new i = 0; i< 38; i++) {
if(i > 18 && i < 22)
continue;
GetWeaponName(i, temp_WName, sizeof(temp_WName));
format(temp_dString, sizeof(temp_dString), "%s%s\t:%d\n", temp_dString, temp_WName, (i >= 22) ? g_PlayerKills[playerid][i-3] : g_PlayerKills[playerid][i]);
}
return ShowPlayerDialog(to_playerid, 8977, DIALOG_STYLE_MSGBOX, "Kill stats!", temp_dString, "OK", "");
}