SHOW:
|
|
- or go back to the newest paste.
| 1 | #define FILTERSCRIPT | |
| 2 | ||
| 3 | #include <a_samp> | |
| 4 | #include <zcmd> | |
| 5 | #include <YSI\y_ini> | |
| 6 | //#include <dini> | |
| 7 | #pragma tabsize 0 | |
| 8 | #define PATH "/MJDM/%s.ini" | |
| 9 | ||
| 10 | new InDM[MAX_PLAYERS]; | |
| 11 | new Float:x1,Float:y1,Float:z1; | |
| 12 | new weapdat[13][2]; | |
| 13 | new cn; | |
| 14 | new skin; | |
| 15 | //new kills[MAX_PLAYERS]; | |
| 16 | //new deaths[MAX_PLAYERS]; | |
| 17 | new Float:Spawns[][]= {
| |
| 18 | {-2491.8706,-237.2221,39.3019,295.0867},
| |
| 19 | {-2482.0308,-283.6506,40.5421,180.7190},
| |
| 20 | {-2444.0479,-271.4679,35.6237,258.4264},
| |
| 21 | {-2490.9055,-298.6101,35.8574,172.5956},
| |
| 22 | {-2525.5771,-313.8878,39.0723,327.6012},
| |
| 23 | {-2554.4729,-291.1451,25.9594,118.0751}
| |
| 24 | }; | |
| 25 | ||
| 26 | new weaps[][] = {
| |
| 27 | {22},
| |
| 28 | {23},
| |
| 29 | {24},
| |
| 30 | {25},
| |
| 31 | {26},
| |
| 32 | {27},
| |
| 33 | {28},
| |
| 34 | {29},
| |
| 35 | {30},
| |
| 36 | {31},
| |
| 37 | {32}
| |
| 38 | }; | |
| 39 | ||
| 40 | enum pInfo | |
| 41 | {
| |
| 42 | pKills, | |
| 43 | pDeaths | |
| 44 | } | |
| 45 | ||
| 46 | new PlayerInfo[MAX_PLAYERS][pInfo]; | |
| 47 | ||
| 48 | forward LoadUser_data(playerid,name[],value[]); | |
| 49 | public LoadUser_data(playerid,name[],value[]) | |
| 50 | {
| |
| 51 | INI_Int("Kills", PlayerInfo[playerid][pKills]);
| |
| 52 | INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
| |
| 53 | return 1; | |
| 54 | } | |
| 55 | ||
| 56 | stock UserPath(playerid) | |
| 57 | {
| |
| 58 | new string[128], pName[MAX_PLAYER_NAME]; | |
| 59 | GetPlayerName(playerid, pName,sizeof(pName)); | |
| 60 | format(string,sizeof(string),PATH,pName); | |
| 61 | return string; | |
| 62 | } | |
| 63 | ||
| 64 | #define COLOR_RED 0xFF3300 | |
| 65 | ||
| 66 | public OnFilterScriptInit() | |
| 67 | {
| |
| 68 | print("\n--------------------------------------");
| |
| 69 | print(" DM[Minigame] by DuskXtremeX");
| |
| 70 | print("--------------------------------------\n");
| |
| 71 | return 1; | |
| 72 | } | |
| 73 | ||
| 74 | public OnFilterScriptExit() | |
| 75 | {
| |
| 76 | return 1; | |
| 77 | } | |
| 78 | ||
| 79 | ||
| 80 | public OnPlayerRequestClass(playerid, classid) | |
| 81 | {
| |
| 82 | SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746); | |
| 83 | SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746); | |
| 84 | SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746); | |
| 85 | return 1; | |
| 86 | } | |
| 87 | ||
| 88 | public OnPlayerConnect(playerid) | |
| 89 | {
| |
| 90 | if(fexist(UserPath(playerid))) | |
| 91 | {
| |
| 92 | INI_ParseFile(UserPath(playerid), "LoadUser_%s",.bExtra =true, .extra =playerid); | |
| 93 | } | |
| 94 | else if(!fexist(UserPath(playerid))) | |
| 95 | {
| |
| 96 | new INI:File = INI_Open(UserPath(playerid)); | |
| 97 | INI_SetTag(File,"PlayerInfo"); | |
| 98 | INI_WriteInt(File,"Kills",0); | |
| 99 | INI_WriteInt(File,"Deaths",0); | |
| 100 | INI_Close(File); | |
| 101 | } | |
| 102 | ||
| 103 | InDM[playerid] =0; | |
| 104 | return 1; | |
| 105 | } | |
| 106 | ||
| 107 | public OnPlayerDisconnect(playerid, reason) | |
| 108 | {
| |
| 109 | new INI:File = INI_Open(UserPath(playerid)); | |
| 110 | INI_SetTag(File,"PlayerInfo"); | |
| 111 | INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); | |
| 112 | INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); | |
| 113 | INI_Close(File); | |
| 114 | - | INI_Close(File); |
| 114 | + | if(InDM[playerid] ==1) |
| 115 | {
| |
| 116 | cn--; | |
| 117 | InDM[playerid] =0; | |
| 118 | } | |
| 119 | CheckWin(); | |
| 120 | return 1; | |
| 121 | } | |
| 122 | ||
| 123 | public OnPlayerSpawn(playerid) | |
| 124 | {
| |
| 125 | ||
| 126 | GivePlayerWeapon(playerid,26,300); | |
| 127 | GivePlayerWeapon(playerid,32,300); | |
| 128 | GivePlayerWeapon(playerid,34,100); | |
| 129 | GivePlayerWeapon(playerid,27,50); | |
| 130 | GetPlayerSkin(skin); | |
| 131 | return 1; | |
| 132 | } | |
| 133 | ||
| 134 | public OnPlayerDeath(playerid, killerid, reason) | |
| 135 | {
| |
| 136 | if(InDM[playerid] ==1) | |
| 137 | {
| |
| 138 | InDM[playerid] =0; | |
| 139 | cn--; | |
| 140 | new str[100]; | |
| 141 | new pName[MAX_PLAYER_NAME],kName[MAX_PLAYER_NAME]; | |
| 142 | - | PlayerInfo[killerid][pKills]++; |
| 142 | + | |
| 143 | GetPlayerName(playerid,pName,MAX_PLAYER_NAME); | |
| 144 | format(str, sizeof(str),"%s(%d) has been killed by %s(%d) in Deathmatch Minigame",pName,kName); | |
| 145 | PlayerInfo[killerid][pKills]++; | |
| 146 | PlayerInfo[playerid][pDeaths]++; | |
| 147 | CheckWin(); | |
| 148 | } | |
| 149 | return 1; | |
| 150 | } | |
| 151 | ||
| 152 | COMMAND:deathmatch(playerid, params[]) | |
| 153 | {
| |
| 154 | ||
| 155 | if(InDM[playerid] ==0) | |
| 156 | {
| |
| 157 | InDM[playerid] =1; | |
| 158 | cn++; | |
| 159 | new p; | |
| 160 | for(p=0;p<13;p++) | |
| 161 | {
| |
| 162 | GetPlayerWeaponData(playerid,p,weapdat[p][0],weapdat[p][1]); | |
| 163 | } | |
| 164 | ResetPlayerWeapons(playerid); | |
| 165 | new string[100]; | |
| 166 | new pName[MAX_PLAYER_NAME]; | |
| 167 | GetPlayerName(playerid,pName,MAX_PLAYER_NAME); | |
| 168 | format(string, sizeof(string), "%s(%d) has joined DM",pName,playerid); | |
| 169 | GetPlayerPos(playerid, x1, y1, z1); | |
| 170 | new Random = random(sizeof(Spawns)); | |
| 171 | SetPlayerPos(playerid, Spawns[Random][0],Spawns[Random][1],Spawns[Random][2]); | |
| 172 | SetPlayerFacingAngle(playerid, Spawns[Random][3]); | |
| 173 | new randomskin = random(50); | |
| 174 | SetPlayerSkin(playerid, randomskin); | |
| 175 | new Random1 = random(sizeof(weaps)); | |
| 176 | GivePlayerWeapon(playerid, weaps[Random1][0], 150); | |
| 177 | } | |
| 178 | else if(InDM[playerid] ==1) | |
| 179 | {
| |
| 180 | SendClientMessage(playerid, COLOR_RED,"You're already in DM"); | |
| 181 | } | |
| 182 | return 1; | |
| 183 | } | |
| 184 | ||
| 185 | - | if(InDM[playerid] ==1) |
| 185 | + | |
| 186 | COMMAND:leavedm(playerid,params[]) | |
| 187 | - | InDM[playerid] =0; |
| 187 | + | |
| 188 | - | cn--; |
| 188 | + | |
| 189 | - | SetPlayerPos(playerid,x1,y1,z1); |
| 189 | + | |
| 190 | - | SetPlayerSkin(playerid,skin); |
| 190 | + | SendClientMessage(playerid, COLOR_RED, "You're not in DM"); |
| 191 | - | ResetPlayerWeapons(playerid); |
| 191 | + | |
| 192 | - | for(new p=0;p<13;p++) |
| 192 | + | |
| 193 | - | {
|
| 193 | + | |
| 194 | - | GivePlayerWeapon(playerid,weapdat[p][0],weapdat[p][1]); |
| 194 | + | ResetPlayer(playerid); // Here I added another Funtion to call. |
| 195 | - | } |
| 195 | + | |
| 196 | return 1; | |
| 197 | - | else if(InDM[playerid] ==0) return SendClientMessage(playerid, COLOR_RED, "You're not in DM"); |
| 197 | + | |
| 198 | - | return 1; |
| 198 | + | |
| 199 | public CheckWin() | |
| 200 | {
| |
| 201 | if(cn ==1) | |
| 202 | {
| |
| 203 | for(new i=0;i<MAX_PLAYERS;i++) | |
| 204 | {
| |
| 205 | if(InDM[i] ==1) | |
| 206 | {
| |
| 207 | new string[128], winner[MAX_PLAYER_NAME]; | |
| 208 | GetPlayerName(i,winner,MAX_PLAYER_NAME); | |
| 209 | format(string,sizeof(string),"%s(%d) Has won the DeathMatch[Minigame]",winner,i); | |
| 210 | SendClientMessageToAll(-1, string); | |
| 211 | ResetPlayer(i); // The same function | |
| 212 | break; | |
| 213 | } | |
| 214 | } | |
| 215 | ||
| 216 | } | |
| 217 | } | |
| 218 | // ADDED THIS JUST TO MAKE IT EASY TO CALL IN "/leavedm" and after winner is announced i.e in 'CheckWin()' | |
| 219 | forward ResetPlayer(playerid); | |
| 220 | public ResetPlayer(playerid) | |
| 221 | {
| |
| 222 | InDM[playerid] =0; | |
| 223 | cn--; | |
| 224 | SetPlayerPos(playerid,x1,y1,z1); | |
| 225 | SetPlayerSkin(playerid,skin); | |
| 226 | ResetPlayerWeapons(playerid); | |
| 227 | for(new p=0;p<13;p++) | |
| 228 | {
| |
| 229 | GivePlayerWeapon(playerid,weapdat[p][0],weapdat[p][1]); | |
| 230 | } | |
| 231 | } |