Код:
#define FILTERSCRIPT
#include <a_samp>
#include <ZCMD>
#include <YSI\y_ini>
#pragma tabsize 0
#define AMMO 100
#define PATH "/Class/%s.ini"
#define SKIN1 165 // Sniper Skin
#define SKIN2 287 // Soldier Skin
enum eTeam
{
pTeam,
pScore
};
new cInfo[MAX_PLAYERS][eTeam];
new tRedScore; // Sniper Score
new tBlueScore; // Soldier Score
forward LoadUser_data(playerid,name[],value[]);
public OnFilterScriptInit()
{
print("\n--------------------------------------");
print(" [LOADING...] Sniper Class - Loaded !");
print(" [LOADING...] Soldier Class - Loaded !");
print("--------------------------------------\n");
return 1;
}
public OnFilterScriptExit()
{
print("\n--------------------------------------");
print(" [LOADING...] Sniper Class - Failed !");
print(" [LOADING...] Soldier Class - Failed !");
print("--------------------------------------\n");
return 1;
}
public OnPlayerSpawn(playerid)
{
if(cInfo[playerid][pTeam] == 1)
GivePlayerWeapon(playerid, 31, 9999);
else if(cInfo[playerid][pTeam] == 2)
GivePlayerWeapon(playerid, 34, 9999);
SetPlayerScore(playerid, cInfo[playerid][pScore]);
if(cInfo[playerid][pTeam] == 1)
SetPlayerSkin(playerid, SKIN1);
else if(cInfo[playerid][pTeam] == 2)
SetPlayerSkin(playerid, SKIN2);
return 1;
}
public OnPlayerConnect(playerid)
{
if(!fexist(UserPath(playerid)))
ShowPlayerDialog(playerid, 112, DIALOG_STYLE_MSGBOX, "Class Selection", "What class you wanna be ?", "Sniper", "Soldier");
else if(fexist(UserPath(playerid)))
INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid);
return 1;
}
public OnPlayerDisconnect(playerid)
{
INI_WriteInt(INI_Open(UserPath(playerid)), "Team", cInfo[playerid][pTeam]);
INI_WriteInt(INI_Open(UserPath(playerid)), "Score", cInfo[playerid][pScore]);
INI_Close(INI_Open(UserPath(playerid)));
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
if(cInfo[killerid][pTeam] == 2)
tBlueScore ++;
else if(cInfo[killerid][pTeam] == 1)
tRedScore ++;
if(tBlueScore == 10)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(cInfo[i][pTeam] != 1)
return 1;
GivePlayerWeapon(i, 38, AMMO);
tBlueScore = 0;
tRedScore = 0;
}
}
else if(tRedScore == 10)
{
for(new i=0; i<MAX_PLAYERS; i++)
{
if(cInfo[i][pTeam] != 2)
return 1;
GivePlayerWeapon(i, 38, AMMO);
tRedScore = 0;
tBlueScore = 0;
}
}
SetPlayerScore(killerid, GetPlayerScore(killerid) + 1);
cInfo[killerid][pScore] ++;
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 112)
{
if(response) cInfo[playerid][pTeam] = 1;
else cInfo[playerid][pTeam] = 2;
new s[128];
format(s,sizeof(s), "You are a %s now ! Enjoy ..", (cInfo[playerid][pTeam] == 1) ? ("Red") : ("Blue"));
SendClientMessage(playerid, 0xFF3567FF, s);
SpawnPlayer(playerid);
}
return 1;
}
public LoadUser_data(playerid,name[],value[])
{
INI_Int("Team", cInfo[playerid][pTeam]);
INI_Int("Score", cInfo[playerid][pScore]);
return 1;
}
CMD:score(playerid, params[])
{
new s[128], s2[128], s3[128];
format(s, sizeof(s), "Red Team Score: %i points", tRedScore);
format(s2, sizeof(s2), "Blue Team Score: %i points", tBlueScore);
format(s3, sizeof(s3), "Your class points: %i", GetPlayerScore(playerid));
SendClientMessage(playerid, 0xFF0000FF, s);
SendClientMessage(playerid, 0x0000FFFF, s2);
SendClientMessage(playerid, 0xFFFF00FF, s3);
return 1;
}
CMD:Class(playerid, params[])
return ShowPlayerDialog(playerid, 112, DIALOG_STYLE_MSGBOX, "Class Selection", "What class you wanna be ?", "Sniper", "Soldier");
stock UserPath(playerid)
{
new String[128],
pName[MAX_PLAYER_NAME];
GetPlayerName(playerid, pName,sizeof(pName));
format(String, sizeof(String), PATH, pName);
return String;
}
INFO
- Saving Score & Class [Player]
- Loading Score & Class [Player]
- Command /class to change your class
- Command /score to see team & your score
- Giving M4 / Sniper at spawn , depending by class
- A skin for each class
- A message when a team have 10 points
- Give a minigun at the all team when team score it's 10
- When a team score it's 10 the other team will get 0 points .
- You need to create folder Class in scriptfiles (/scriptfiles/Class/) = There will save Score and class of the player
- I hope you enjoy it and don't forget to click +REP button