15.11.2009, 12:34
Someone REQUESTED This to me I've been asked many times, "How do you make a Character Kill for my Roleplay Server" etc... Well I'm tired of it so i made a add-on for people's Roleplay server. This was pulled straight out from my Roleplay server.
Notice - Fuck my indentation!
Before we begin You need to add this code, this code separates....[Hard to Explain fuck it]
Step 1: We are going to use enumeration for this, So Put this under your includes.
This will make up to 10 CK allowed you can edit the [10] to make more CKs allowed!
Step 2: We Have to load and save the cks to work right?
The Code up There Loads it and the one below saves it!
Step 3: Now You will have to make sure that when a player connects with a name his name is CKed or not. Now this code does so, add this to your OnPlayerConnect:
Step 4 Now we need to make a admin command that makes you CK someone! Put this under OnPlayerCommandText
All done making a CK system the ck.txt file is in the attachments!
Notice: If you are too lazy, or your getting warnings or errors. Than you may download this whole ck system in the attachments also!
Notice - Fuck my indentation!
Before we begin You need to add this code, this code separates....[Hard to Explain fuck it]
Код:
forward split(const strsrc[], strdest[][], delimiter);
public split(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc)){
if(strsrc[i]==delimiter || i==strlen(strsrc)){
len = strmid(strdest[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
Код:
enum CKInfo
{
Player[MAX_PLAYER_NAME],
Killer[MAX_PLAYER_NAME],
Month,
Day,
Year
}
new CharacterKillInfo[10][CKInfo];
Step 2: We Have to load and save the cks to work right?
Код:
forward LoadCK();
public LoadCK()
{
new arrCoords[33][64];
new strFromFile2[256];
new File: file = fopen("CK.txt", io_read);
if (file)
{
new idx;
while (idx < sizeof(CharacterKillInfo))
{
fread(file, strFromFile2);
split(strFromFile2, arrCoords, '|');
strmid(CharacterKillInfo[idx][Player], arrCoords[0], 0, strlen(arrCoords[0]), 255);
strmid(CharacterKillInfo[idx][Killer], arrCoords[1], 0, strlen(arrCoords[1]), 255);
CharacterKillInfo[idx][Month] = strval(arrCoords[2]);
CharacterKillInfo[idx][Day] = strval(arrCoords[3]);
CharacterKillInfo[idx][Year] = strval(arrCoords[4]);
print("---------------------------------");
printf("CKid %d - PlayerKilled: %s - Killer %s",idx,CharacterKillInfo[idx][Player],CharacterKillInfo[idx][Killer]);
print("---------------------------------");
idx++;
}
}
fclose(file);
return 1;
}
Код:
forward SaveCK();
public SaveCK()
{
new idx;
new File: file2;
while (idx < sizeof(CharacterKillInfo))
{
new coordsstring[512];
format(coordsstring, sizeof(coordsstring), "%s|%s|%d|%d|%d\n",
CharacterKillInfo[idx][Player],
CharacterKillInfo[idx][Killer],
CharacterKillInfo[idx][Month],
CharacterKillInfo[idx][Day],
CharacterKillInfo[idx][Year]);
if(idx == 0)
{
file2 = fopen("CK.txt", io_write);
}
else
{
file2 = fopen("CK.txt", io_append);
}
fwrite(file2, coordsstring);
idx++;
fclose(file2);
}
return 1;
}
Код:
new time;
new string[128];
new playername[MAX_PLAYER_NAME];
GetPlayerName(playerid, playername, sizeof(playername));
if(strcmp(playername, CharacterKillInfo[playerid][Player], true) == 0)
{
SendClientMessage(playerid, 0xAA3333AA, "[Attention] = You're listed in the CK GTFO");
format(string, sizeof(string), "Date Died - %d %d %d [Month,Day,Year]", CharacterKillInfo[time][Month],CharacterKillInfo[time][Day],CharacterKillInfo[time][Year]);
SendClientMessage(playerid, 0xAA3333AA, string);
Kick(playerid);
return 1;
}
Код:
new tmp[128];
new idx;
new giveplayerid;
if (strcmp("/ack", cmdtext, true, 10) == 0)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
if(IsPlayerAdmin(playerid))
{
tmp = strtok(cmdtext, idx);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xAA3333AA, "USAGE: /ack [playerid]");
giveplayerid = strval(tmp);
new plname[MAX_PLAYER_NAME];
GetPlayerName(playerid, plname, sizeof(plname));
CharacterKillInfo[giveplayerid][Player] = plname;
new dYear, dMonth, dDay;
getdate(dYear, dMonth, dDay);
CharacterKillInfo[giveplayerid][Month] = dMonth;
CharacterKillInfo[giveplayerid][Day] = dDay;
CharacterKillInfo[giveplayerid][Year] = dYear;
SendClientMessage(giveplayerid, 0xAA3333AA, "You have been character killed!");
Kick(giveplayerid);
}
}
return 1;
}
Notice: If you are too lazy, or your getting warnings or errors. Than you may download this whole ck system in the attachments also!

