Death Reasons Array -
dowster - 30.07.2011
To save others time, and for personal use i created an array of all the deathreasons 0 - 255. The lines that say invalid are for the reason numbers that aren't used, and are basically just placeholders, 255 is a vehicle explosion, this occurs when standing next to an exploding vehicle or inside an exploding vehicle. 200 and 201 are connect/disconnect, and the lower numbers are from weapons. An example of the usage for this would be:
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
new string[96], deadplayer[MAX_PLAYER_NAME], killer[MAX_PLAYER_NAME], hour, minute, second, year, month, day, Float:x, Float:y, Float:z, chospital, Float:sdistance;
gettime( hour, minute, second);
getdate( year, month, day);
GetPlayerName( playerid, deadplayer, sizeof(deadplayer));
if (IsPlayerConnected(killerid))
{
GetPlayerName( killerid, killer, sizeof(killer));
format(string, sizeof(string), "[%s %i, %i] - [%i:%i:%i] - %s killed %s, with a %s\r\n", Months[month], day, year, hour, minute, second, killer, deadplayer, DeathReason[reason]);
}
else
{
format(string, sizeof(string), "[%s %i, %i] - [%i:%i:%i] - %s has died from %s\r\n", Months[month], day, year, hour, minute, second, deadplayer, DeathReason[reason]);
}
SendClientMessageToAll( COLOR_RED, string);
new File:deathlog = fopen("Logs/Death Log.txt", io_append);
fwrite(deathlog, string);
fclose(deathlog);
return 1;
}
feel free to use the above example if you want, but you must place my name in the credits somewhere in your script.
All you need to do is
at the top of your script and it should work.
Re: Death Reasons Array -
Donya - 30.07.2011
Am I going crazy or there is not a download.
Re: Death Reasons Array -
dowster - 30.07.2011
haha nahh im the crazy one, thanks for the notice
Edit: ok, i didnt notice the invalid file error the first time, its in a .rar because it wouldnt accept the .inc
Re: Death Reasons Array -
Donya - 30.07.2011
Click on this to show wonders that accept's .inc
Re: Death Reasons Array -
dowster - 31.07.2011
@donya
Didn't i say i was crazy :P lol
@-razor-
It's shown in the example, but really its just an array with all the ways you could die typed into it, it could be useful also if your making a weapons selection menu. you could use sscanf and have it scan row to row until it gets a match for the weapon the player has typed in, or do a loop in format and have it auto generate a list of weapons in a dialog. up to you what you do with it.
Re: Death Reasons Array -
MA_proking - 31.07.2011
Код:
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : error 017: undefined symbol "Months"
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : warning 215: expression has no effect
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : error 001: expected token: ";", but found "]"
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Can you help error with this line
pawn Код:
format(string, sizeof(string), "[%s %i, %i] - [%i:%i:%i] - %s killed %s, with a %s\r\n", Months[month], day, year, hour, minute, second, killer, deadplayer, DeathReason[reason]);
Re: Death Reasons Array -
Lorenc_ - 31.07.2011
(Optional) Add this as well:
pawn Код:
#define GetDeathReason(%1) (DeathReason[%1])
instead of DeathReason[reason] whilst using a array this little define makes it look like a function.
pawn Код:
if(GetDeathReason(reason) == WEAPON_KNIFE) SendClientMessage(playerid, -1, "You have been killed by a knife");
Looks good, I cannot belive you bothered to go through all of that lol
Nice.
Re: Death Reasons Array -
dowster - 31.07.2011
The example wasn't meant to be pasted, since my pc is currently frozen with gta running I can't get to the months array, you can take it from my network stats log filterscript.
@lorenc_ I had that and the wiki page side by side in notepad++ lol, it wasn't to bad but I wanted to save others the cubicle work
Edit, re reading your post Lorenc_ i dont quite understand what you meant with the define, could you elaborate please?
Re: Death Reasons Array -
Darnell - 09.08.2011
Quote:
Originally Posted by MA_proking
Код:
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : error 017: undefined symbol "Months"
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : warning 215: expression has no effect
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : error 001: expected token: ";", but found "]"
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : error 029: invalid expression, assumed zero
C:\DOCUME~1\Prabhat\Desktop\WORLDS~1.5\GAMEMO~1\lvdm.pwn(2413) : fatal error 107: too many error messages on one line
Compilation aborted.Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
4 Errors.
Can you help error with this line
pawn Код:
format(string, sizeof(string), "[%s %i, %i] - [%i:%i:%i] - %s killed %s, with a %s\r\n", Months[month], day, year, hour, minute, second, killer, deadplayer, DeathReason[reason]);
|
pawn Код:
format(string, sizeof(string), "[%s %i, %i] - [%i:%i:%i] - %s has died from %s\r\n", month,day,year,hour,minute,second,deadplayer,DeathReason[reason]);
Re: Death Reasons Array -
dowster - 09.08.2011
Quote:
Originally Posted by Darnell
pawn Код:
format(string, sizeof(string), "[%s %i, %i] - [%i:%i:%i] - %s has died from %s\r\n", month,day,year,hour,minute,second,deadplayer,DeathReason[reason]);
|
that would work to for getting the month number, i have another array with all the months stored as text for the purpose of making my logs a bit easier to read. you would also then need to change the first string to integer
pawn Код:
format(string, sizeof(string), "[%i %i, %i] - [%i:%i:%i] - %s has died from %s\r\n", month,day,year,hour,minute,second,deadplayer,DeathReason[reason]);