SHOW:
|
|
- or go back to the newest paste.
1 | #define FILTERSCRIPT | |
2 | #include <a_samp> | |
3 | #include <y_ini> | |
4 | #include <zcmd> | |
5 | #include <sscanf> | |
6 | ||
7 | #define PATH "XPUsers/%.ini" | |
8 | ||
9 | // Experience - System [Y_INI] // | |
10 | ||
11 | enum pInfo | |
12 | { | |
13 | XP | |
14 | } | |
15 | new PlayerInfo[MAX_PLAYERS][pInfo]; | |
16 | ||
17 | forward LoadUser_XP(playerid,name[],value[]); | |
18 | public LoadUser_XP(playerid,name[],value[]) | |
19 | { | |
20 | INI_Int("XP",PlayerInfo[playerid][XP]); | |
21 | return 1; | |
22 | } | |
23 | ||
24 | stock UserPath(playerid) | |
25 | { | |
26 | new string[128],playername[MAX_PLAYER_NAME]; | |
27 | GetPlayerName(playerid,playername,sizeof(playername)); | |
28 | format(string,sizeof(string),PATH,playername); | |
29 | return string; | |
30 | } | |
31 | ||
32 | ||
33 | new Text:Textdraw0; | |
34 | new Text:Textdraw1[MAX_PLAYERS]; | |
35 | ||
36 | public OnFilterScriptInit() | |
37 | { | |
38 | print("Loading Experience system..."); | |
39 | print("KyleG/RyderX's Experience system loaded!"); | |
40 | ||
41 | // Create the textdraws: | |
42 | Textdraw0 = TextDrawCreate(510.000000, 390.000000, "EXPERIENCE:"); | |
43 | TextDrawBackgroundColor(Textdraw0, 255); | |
44 | TextDrawFont(Textdraw0, 3); | |
45 | TextDrawLetterSize(Textdraw0, 0.529999, 1.800000); | |
46 | TextDrawColor(Textdraw0, 65535); | |
47 | TextDrawSetOutline(Textdraw0, 1); | |
48 | TextDrawSetProportional(Textdraw0, 1); | |
49 | ||
50 | for(new i; i < MAX_PLAYERS; i ++) | |
51 | { | |
52 | ||
53 | Textdraw1[i] = TextDrawCreate(511.000000, 417.000000, ""); | |
54 | TextDrawBackgroundColor(Textdraw1[i], 255); | |
55 | TextDrawFont(Textdraw1[i], 0); | |
56 | TextDrawLetterSize(Textdraw1[i], 0.519999, 1.900000); | |
57 | TextDrawColor(Textdraw1[i], 16777215); | |
58 | TextDrawSetOutline(Textdraw1[i], 1); | |
59 | TextDrawSetProportional(Textdraw1[i], 1); | |
60 | ||
61 | } | |
62 | return 1; | |
63 | } | |
64 | ||
65 | public OnPlayerSpawn(playerid) | |
66 | { | |
67 | TextDrawShowForPlayer(playerid, Textdraw0); | |
68 | TextDrawShowForPlayer(playerid, Textdraw1[playerid]); | |
69 | return 1; | |
70 | } | |
71 | ||
72 | public OnPlayerConnect(playerid) | |
73 | { | |
74 | SendClientMessage(playerid, 0xfff888f88, "Welcome! This server is using EXP system! kill other to get More XPs!"); | |
75 | return 1; | |
76 | } | |
77 | ||
78 | public OnPlayerUpdate(playerid) | |
79 | { | |
80 | new string[128]; | |
81 | format(string, sizeof(string), "%d", PlayerInfo[playerid][XP]); | |
82 | TextDrawSetString(Textdraw1[playerid], string); | |
83 | TextDrawShowForPlayer(playerid, Textdraw1[playerid]); | |
84 | return 1; | |
85 | } | |
86 | ||
87 | public OnPlayerDeath(playerid, killerid, reason) | |
88 | { | |
89 | new string[250]; new name[MAX_PLAYER_NAME]; new kname[MAX_PLAYER_NAME]; | |
90 | GetPlayerName(playerid, name,sizeof(name)); | |
91 | GetPlayerName(killerid, kname,sizeof(kname)); | |
92 | format(string,sizeof(string),"-DM- {F00f00}%s(%i) {ffffff}has killed {f00f00}%s(%i) {FFFFFF}and got {f00f00} +2 XP!",kname,killerid,name,playerid); | |
93 | SendClientMessageToAll(0xf8f8f8fff,string); | |
94 | PlayerInfo[killerid][XP] += 2; //you can change XP's value as the amount you want. | |
95 | return 1; | |
96 | } | |
97 | ||
98 | //COMMANDS// | |
99 | CMD:givexp(playerid, params[]) | |
100 | { | |
101 | if(IsPlayerAdmin(playerid)) | |
102 | { | |
103 | new targetid; | |
104 | new maxxp; | |
105 | new string[128]; | |
106 | new pname[MAX_PLAYER_NAME]; | |
107 | new tname[MAX_PLAYER_NAME]; | |
108 | if(sscanf(params, "ii", targetid, maxxp)) return SendClientMessage(playerid, 0xF8F8F8FFF, "Syntax: {F00f00}/givexp [ID] [amount]"); | |
109 | if((!IsPlayerConnected(targetid)) || (targetid == INVALID_PLAYER_ID)) return SendClientMessage(playerid, 0xFF0000, "ERROR: {FFFFFF}Player isn't Connected!"); | |
110 | if(maxxp < 0 || maxxp > 100000) return SendClientMessage(playerid, 0xF8F8F8FFF, "ERROR: {FFFFFF}highest amount is 100000."); | |
111 | GetPlayerName(playerid, pname, sizeof(pname)); | |
112 | GetPlayerName(targetid, tname, sizeof(tname)); | |
113 | format(string, sizeof(string), "{99bec3}Administrator {FFD700}%s {99bec3}has {15ff00}gave {FFD700}%s {FFD700}%i {99bec3}XP!", pname, tname, maxxp); | |
114 | SendClientMessageToAll(0xF8F8F8FFF, string); | |
115 | GameTextForPlayer(targetid,"~W~W~P~O~R~W! ~Y~N~G~I~R~C~P~E! ~Y~X~P~P ~R~:)",3000,3); | |
116 | new INI:File = INI_Open(UserPath(targetid)); | |
117 | PlayerInfo[targetid][XP] += maxxp; | |
118 | INI_WriteInt(File,"XP",maxxp); | |
119 | INI_Close(File); | |
120 | } | |
121 | else | |
122 | { | |
123 | SendClientMessage(playerid, 0xf8F8F8FFF,"ERROR: {FFFFFF}You aren't authorized to use this command."); | |
124 | } | |
125 | return 1; | |
126 | } | |
127 | ||
128 | CMD:setxp(playerid, params[]) | |
129 | { | |
130 | if(IsPlayerAdmin(playerid)) | |
131 | { | |
132 | new targetid; | |
133 | new maxxp; | |
134 | new string[128]; | |
135 | new pname[MAX_PLAYER_NAME]; | |
136 | new tname[MAX_PLAYER_NAME]; | |
137 | ||
138 | if(sscanf(params, "ii", targetid, maxxp)) return SendClientMessage(playerid, 0xF8F8F8FFF, "Syntax: {F00f00}/setxp [ID] [amount]"); | |
139 | if((!IsPlayerConnected(targetid)) || (targetid == INVALID_PLAYER_ID)) return SendClientMessage(playerid, 0xFF0000, "ERROR: {FFFFFF}Player isn't Connected!"); | |
140 | if(maxxp < 0 || maxxp > 1000000) return SendClientMessage( playerid, 0xF8F8F8FFF, "ERROR: {FFFFFF}highest amount is 1000000."); | |
141 | GetPlayerName(playerid, pname, sizeof(pname)); | |
142 | GetPlayerName(targetid, tname, sizeof(tname)); | |
143 | format(string, sizeof(string), "{99bec3}Administrator {FFD700}%s {99bec3}has set {FFD700}%s {15ff00}XP {99bec3}Amount to {FFD700}%i{99bec3}.", pname, tname, maxxp); | |
144 | SendClientMessageToAll(0xF8F8F8FFF, string); | |
145 | new INI:File = INI_Open(UserPath(targetid)); | |
146 | PlayerInfo[targetid][XP] = maxxp; | |
147 | INI_WriteInt(File,"XP",maxxp); | |
148 | INI_Close(File); | |
149 | } | |
150 | else | |
151 | { | |
152 | SendClientMessage(playerid, 0xf8F8F8FFF,"ERROR: {FFFFFF}You aren't authorized to use this command."); | |
153 | } | |
154 | return 1; | |
155 | } |