[Include] Death Reasons Array
#1

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
pawn Код:
#include <deathreasons>
at the top of your script and it should work.
Reply
#2

Am I going crazy or there is not a download.
Reply
#3

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
Reply
#4

Click on this to show wonders that accept's .inc
Reply
#5

@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.
Reply
#6

Код:
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]);
Reply
#7

(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.
Reply
#8

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?
Reply
#9

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]);
Reply
#10

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]);
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)