SHOW:
|
|
- or go back to the newest paste.
| 1 | //Credits to Y_Less, Dracoblue and Kush. | |
| 2 | ||
| 3 | #include <a_samp> | |
| 4 | #include <YSI\y_ini> | |
| 5 | #include <sscanf2> | |
| 6 | #include <pvehicle> | |
| 7 | ||
| 8 | #define dcmd(%1,%2,%3) if (!strcmp((%3)[1], #%1, true, (%2)) && ((((%3)[(%2) + 1] == '\0') && (dcmd_%1(playerid, ""))) || (((%3)[(%2) + 1] == ' ') && (dcmd_%1(playerid, (%3)[(%2) + 2]))))) return 1 | |
| 9 | ||
| 10 | #define DIALOG_REGISTER 1 | |
| 11 | #define DIALOG_LOGIN 2 | |
| 12 | #define DIALOG_SUCCESS_1 3 | |
| 13 | #define DIALOG_SUCCESS_2 4 | |
| 14 | #define DIALOG_ADVEHICLES 5 | |
| 15 | ||
| 16 | #define PATH "/Users/%s.ini" | |
| 17 | ||
| 18 | #define COL_WHITE "{FFFFFF}"
| |
| 19 | #define COL_RED "{F81414}"
| |
| 20 | #define COL_GREEN "{00FF22}"
| |
| 21 | #define COL_LIGHTBLUE "{00CED1}"
| |
| 22 | ||
| 23 | enum pInfo | |
| 24 | {
| |
| 25 | pPass, | |
| 26 | pCash, | |
| 27 | pAdmin, | |
| 28 | pKills, | |
| 29 | - | pDeaths |
| 29 | + | pDeaths, |
| 30 | pVip | |
| 31 | } | |
| 32 | new PlayerInfo[MAX_PLAYERS][pInfo]; | |
| 33 | ||
| 34 | forward LoadUser_data(playerid,name[],value[]); | |
| 35 | public LoadUser_data(playerid,name[],value[]) | |
| 36 | {
| |
| 37 | INI_Int("Password",PlayerInfo[playerid][pPass]);
| |
| 38 | INI_Int("Cash",PlayerInfo[playerid][pCash]);
| |
| 39 | INI_Int("Admin",PlayerInfo[playerid][pAdmin]);
| |
| 40 | INI_Int("Kills",PlayerInfo[playerid][pKills]);
| |
| 41 | INI_Int("Deaths",PlayerInfo[playerid][pDeaths]);
| |
| 42 | INI_Int("VIP",PlayerInfo[playerid][pVip]);
| |
| 43 | return 1; | |
| 44 | } | |
| 45 | ||
| 46 | stock UserPath(playerid) | |
| 47 | {
| |
| 48 | new string[128],playername[MAX_PLAYER_NAME]; | |
| 49 | GetPlayerName(playerid,playername,sizeof(playername)); | |
| 50 | format(string,sizeof(string),PATH,playername); | |
| 51 | return string; | |
| 52 | } | |
| 53 | - | stock udb_hash(buf[]) {
|
| 53 | + | |
| 54 | - | new length=strlen(buf); |
| 54 | + | |
| 55 | - | new s1 = 1; |
| 55 | + | stock udb_hash(buf[]) |
| 56 | - | new s2 = 0; |
| 56 | + | |
| 57 | - | new n; |
| 57 | + | new length=strlen(buf); |
| 58 | - | for (n=0; n<length; n++) |
| 58 | + | new s1 = 1; |
| 59 | new s2 = 0; | |
| 60 | - | s1 = (s1 + buf[n]) % 65521; |
| 60 | + | new n; |
| 61 | - | s2 = (s2 + s1) % 65521; |
| 61 | + | for (n=0; n<length; n++) |
| 62 | {
| |
| 63 | - | return (s2 << 16) + s1; |
| 63 | + | s1 = (s1 + buf[n]) % 65521; |
| 64 | s2 = (s2 + s1) % 65521; | |
| 65 | } | |
| 66 | return (s2 << 16) + s1; | |
| 67 | } | |
| 68 | ||
| 69 | main() | |
| 70 | {
| |
| 71 | print("\n----------------------------------");
| |
| 72 | print(" Blank Gamemode by your name here");
| |
| 73 | print("----------------------------------\n");
| |
| 74 | } | |
| 75 | ||
| 76 | public OnGameModeInit() | |
| 77 | {
| |
| 78 | SetGameModeText("World War lll");
| |
| 79 | return 1; | |
| 80 | } | |
| 81 | ||
| 82 | public OnGameModeExit() | |
| 83 | {
| |
| 84 | return 1; | |
| 85 | } | |
| 86 | ||
| 87 | public OnPlayerRequestClass(playerid, classid) | |
| 88 | {
| |
| 89 | return 1; | |
| 90 | } | |
| 91 | ||
| 92 | public OnPlayerConnect(playerid) | |
| 93 | {
| |
| 94 | if(fexist(UserPath(playerid))) | |
| 95 | {
| |
| 96 | INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); | |
| 97 | ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_WHITE"Type your password below to login.","Login","Quit"); | |
| 98 | } | |
| 99 | else | |
| 100 | {
| |
| 101 | ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit"); | |
| 102 | } | |
| 103 | return 1; | |
| 104 | } | |
| 105 | ||
| 106 | public OnPlayerDisconnect(playerid, reason) | |
| 107 | {
| |
| 108 | new INI:File = INI_Open(UserPath(playerid)); | |
| 109 | INI_SetTag(File,"data"); | |
| 110 | INI_WriteInt(File,"Cash",GetPlayerMoney(playerid)); | |
| 111 | INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]); | |
| 112 | INI_WriteInt(File,"Kills",PlayerInfo[playerid][pKills]); | |
| 113 | INI_WriteInt(File,"Deaths",PlayerInfo[playerid][pDeaths]); | |
| 114 | INI_WriteInt(File,"VIP",PlayerInfo[playerid][pVip]); | |
| 115 | INI_Close(File); | |
| 116 | return 1; | |
| 117 | } | |
| 118 | ||
| 119 | public OnPlayerSpawn(playerid) | |
| 120 | {
| |
| 121 | return 1; | |
| 122 | } | |
| 123 | ||
| 124 | public OnPlayerDeath(playerid, killerid, reason) | |
| 125 | {
| |
| 126 | PlayerInfo[killerid][pKills]++; | |
| 127 | PlayerInfo[playerid][pDeaths]++; | |
| 128 | return 1; | |
| 129 | } | |
| 130 | ||
| 131 | public OnVehicleSpawn(vehicleid) | |
| 132 | {
| |
| 133 | return 1; | |
| 134 | } | |
| 135 | ||
| 136 | public OnVehicleDeath(vehicleid, killerid) | |
| 137 | {
| |
| 138 | return 1; | |
| 139 | } | |
| 140 | ||
| 141 | public OnPlayerText(playerid, text[]) | |
| 142 | {
| |
| 143 | return 1; | |
| 144 | } | |
| 145 | ||
| 146 | public OnPlayerCommandText(playerid, cmdtext[]) | |
| 147 | - | dcmd(advehicles, 10, cmdtext); |
| 147 | + | |
| 148 | //Admin Commands | |
| 149 | dcmd(sethealth, 9, cmdtext); | |
| 150 | dcmd(kick, 4, cmdtext); | |
| 151 | dcmd(advehicles, 10, cmdtext); //Line 151 | |
| 152 | return 0; | |
| 153 | } | |
| 154 | ||
| 155 | dcmd_sethealth(playerid, params[]) | |
| 156 | {
| |
| 157 | - | |
| 157 | + | |
| 158 | {
| |
| 159 | new id, Float:amount, string[70], pName[MAX_PLAYER_NAME]; // Create the variables needed for this command. id = the id we want to set the health of, amount = the amount we're gonna set id's health to and pName is just where we store id's name. | |
| 160 | if(sscanf(params, "uf", id, amount)) return SendClientMessage(playerid, 0xFF0000AA, "Usage: /sethealth (id) (amount)"); | |
| 161 | ||
| 162 | if(!IsPlayerConnected(id)) return SendClientMessage(playerid, 0xFF0000AA, "This player is not connected."); // ID is not connected, send an error message | |
| 163 | else | |
| 164 | {
| |
| 165 | GetPlayerName(id, pName, MAX_PLAYER_NAME); | |
| 166 | SetPlayerHealth(id, amount); | |
| 167 | format(string, sizeof(string), "You've Set %s's (%d) Health To %d.", pName, id, amount); | |
| 168 | SendClientMessage(playerid, 0x00FF00AA, string); | |
| 169 | return 1; | |
| 170 | } | |
| 171 | } | |
| 172 | else SendClientMessage(playerid, 0xFF0000FF, "ERROR: You need to be Level 4 to use this command."); | |
| 173 | return 1; | |
| 174 | } | |
| 175 | ||
| 176 | dcmd_kick(playerid, params[]) | |
| 177 | {
| |
| 178 | if(PlayerInfo[playerid][pAdmin] == 4 || IsPlayerAdmin(playerid)) | |
| 179 | {
| |
| 180 | new id; | |
| 181 | new reason[64]; | |
| 182 | new idName[MAX_PLAYER_NAME]; | |
| 183 | new playeridName[MAX_PLAYER_NAME]; | |
| 184 | if(sscanf(params,"uz", id, reason)) SendClientMessage(playerid, 0xFF0000FF, "Usage: /kick (id) (reason)"); | |
| 185 | else if (id == INVALID_PLAYER_ID) SendClientMessage(playerid, 0xFF0000FF, "ERROR: Player not found"); | |
| 186 | - | SendClientMessage(id, 0xFF0000FF, "You have been kicked by Administrator %s. Reason: %s", playeridName, reason); |
| 186 | + | |
| 187 | {
| |
| 188 | - | SendClientMessage(playerid, 0xFF0000FF, "You have succesfully kicked %s for reason: %s", idName, reason); |
| 188 | + | |
| 189 | GetPlayerName(playerid, playeridName, MAX_PLAYER_NAME); | |
| 190 | SendClientMessage(id, 0xFF0000FF, "You have been kicked by Administrator %s. Reason: %s", playeridName, reason); //Line 190 | |
| 191 | Kick(id); | |
| 192 | SendClientMessage(playerid, 0xFF0000FF, "You have succesfully kicked %s for reason: %s", idName, reason); //Line 192 | |
| 193 | return 1; | |
| 194 | } | |
| 195 | } | |
| 196 | else SendClientMessage(playerid, 0xFF0000FF, "ERROR: You need to be Level 4 to use this command."); | |
| 197 | return 1; | |
| 198 | } | |
| 199 | ||
| 200 | dcmd_advehicles(playerid) | |
| 201 | {
| |
| 202 | if(PlayerInfo[playerid][pAdmin] == 2 || IsPlayerAdmin(playerid)) | |
| 203 | {
| |
| 204 | ShowPlayerDialog(playerid, DIALOG_ADVEHICLES, DIALOG_STYLE_LIST, "Admin Vehicles", "Rhino\nHydra\nPatriot\nHunter\nMaverick\nS.W.A.T. Van\nBarracks\nFiretruck", "Spawn", "Cancel"); | |
| 205 | } | |
| 206 | - | |
| 206 | + | |
| 207 | return 1; | |
| 208 | } | |
| 209 | ||
| 210 | ||
| 211 | ||
| 212 | public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger) | |
| 213 | {
| |
| 214 | return 1; | |
| 215 | } | |
| 216 | ||
| 217 | public OnPlayerExitVehicle(playerid, vehicleid) | |
| 218 | {
| |
| 219 | return 1; | |
| 220 | } | |
| 221 | ||
| 222 | public OnPlayerStateChange(playerid, newstate, oldstate) | |
| 223 | {
| |
| 224 | return 1; | |
| 225 | } | |
| 226 | ||
| 227 | public OnPlayerEnterCheckpoint(playerid) | |
| 228 | {
| |
| 229 | return 1; | |
| 230 | } | |
| 231 | ||
| 232 | public OnPlayerLeaveCheckpoint(playerid) | |
| 233 | {
| |
| 234 | return 1; | |
| 235 | } | |
| 236 | ||
| 237 | public OnPlayerEnterRaceCheckpoint(playerid) | |
| 238 | {
| |
| 239 | return 1; | |
| 240 | } | |
| 241 | ||
| 242 | public OnPlayerLeaveRaceCheckpoint(playerid) | |
| 243 | {
| |
| 244 | return 1; | |
| 245 | } | |
| 246 | ||
| 247 | public OnRconCommand(cmd[]) | |
| 248 | {
| |
| 249 | return 1; | |
| 250 | } | |
| 251 | ||
| 252 | public OnPlayerRequestSpawn(playerid) | |
| 253 | {
| |
| 254 | return 1; | |
| 255 | } | |
| 256 | ||
| 257 | public OnObjectMoved(objectid) | |
| 258 | {
| |
| 259 | return 1; | |
| 260 | } | |
| 261 | ||
| 262 | public OnPlayerObjectMoved(playerid, objectid) | |
| 263 | {
| |
| 264 | return 1; | |
| 265 | } | |
| 266 | ||
| 267 | public OnPlayerPickUpPickup(playerid, pickupid) | |
| 268 | {
| |
| 269 | return 1; | |
| 270 | } | |
| 271 | ||
| 272 | public OnVehicleMod(playerid, vehicleid, componentid) | |
| 273 | {
| |
| 274 | return 1; | |
| 275 | } | |
| 276 | ||
| 277 | public OnVehiclePaintjob(playerid, vehicleid, paintjobid) | |
| 278 | {
| |
| 279 | return 1; | |
| 280 | } | |
| 281 | ||
| 282 | public OnVehicleRespray(playerid, vehicleid, color1, color2) | |
| 283 | {
| |
| 284 | return 1; | |
| 285 | } | |
| 286 | ||
| 287 | public OnPlayerSelectedMenuRow(playerid, row) | |
| 288 | {
| |
| 289 | return 1; | |
| 290 | } | |
| 291 | ||
| 292 | public OnPlayerExitedMenu(playerid) | |
| 293 | {
| |
| 294 | return 1; | |
| 295 | } | |
| 296 | ||
| 297 | public OnPlayerInteriorChange(playerid, newinteriorid, oldinteriorid) | |
| 298 | {
| |
| 299 | return 1; | |
| 300 | } | |
| 301 | ||
| 302 | public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) | |
| 303 | {
| |
| 304 | return 1; | |
| 305 | } | |
| 306 | ||
| 307 | public OnRconLoginAttempt(ip[], password[], success) | |
| 308 | {
| |
| 309 | return 1; | |
| 310 | } | |
| 311 | ||
| 312 | public OnPlayerUpdate(playerid) | |
| 313 | {
| |
| 314 | return 1; | |
| 315 | } | |
| 316 | ||
| 317 | public OnPlayerStreamIn(playerid, forplayerid) | |
| 318 | {
| |
| 319 | return 1; | |
| 320 | } | |
| 321 | ||
| 322 | public OnPlayerStreamOut(playerid, forplayerid) | |
| 323 | {
| |
| 324 | return 1; | |
| 325 | } | |
| 326 | ||
| 327 | public OnVehicleStreamIn(vehicleid, forplayerid) | |
| 328 | {
| |
| 329 | return 1; | |
| 330 | } | |
| 331 | ||
| 332 | public OnVehicleStreamOut(vehicleid, forplayerid) | |
| 333 | {
| |
| 334 | return 1; | |
| 335 | - | switch( dialogid ) |
| 335 | + | |
| 336 | ||
| 337 | public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[]) | |
| 338 | {
| |
| 339 | switch(dialogid) | |
| 340 | {
| |
| 341 | case DIALOG_REGISTER: | |
| 342 | {
| |
| 343 | if (!response) return Kick(playerid); | |
| 344 | if(response) | |
| 345 | {
| |
| 346 | if(!strlen(inputtext)) return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT, ""COL_WHITE"Registering...",""COL_RED"You have entered an invalid password.\n"COL_WHITE"Type your password below to register a new account.","Register","Quit"); | |
| 347 | new INI:File = INI_Open(UserPath(playerid)); | |
| 348 | INI_SetTag(File,"data"); | |
| 349 | INI_WriteInt(File,"Password",udb_hash(inputtext)); | |
| 350 | INI_WriteInt(File,"Cash",0); | |
| 351 | INI_WriteInt(File,"Admin",0); | |
| 352 | INI_WriteInt(File,"Kills",0); | |
| 353 | INI_WriteInt(File,"Deaths",0); | |
| 354 | INI_Close(File); | |
| 355 | ||
| 356 | SetSpawnInfo(playerid, 0, 0, 1958.33, 1343.12, 15.36, 269.15, 0, 0, 0, 0, 0, 0); | |
| 357 | SpawnPlayer(playerid); | |
| 358 | ShowPlayerDialog(playerid, DIALOG_SUCCESS_1, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"Great! Your Y_INI system works perfectly. Relog to save your stats!","Ok",""); | |
| 359 | } | |
| 360 | } | |
| 361 | ||
| 362 | case DIALOG_LOGIN: | |
| 363 | {
| |
| 364 | if ( !response ) return Kick ( playerid ); | |
| 365 | if( response ) | |
| 366 | {
| |
| 367 | if(udb_hash(inputtext) == PlayerInfo[playerid][pPass]) | |
| 368 | {
| |
| 369 | INI_ParseFile(UserPath(playerid), "LoadUser_%s", .bExtra = true, .extra = playerid); | |
| 370 | GivePlayerMoney(playerid, PlayerInfo[playerid][pCash]); | |
| 371 | ShowPlayerDialog(playerid, DIALOG_SUCCESS_2, DIALOG_STYLE_MSGBOX,""COL_WHITE"Success!",""COL_GREEN"You have successfully logged in!","Ok",""); | |
| 372 | } | |
| 373 | else | |
| 374 | {
| |
| 375 | ShowPlayerDialog(playerid, DIALOG_LOGIN, DIALOG_STYLE_INPUT,""COL_WHITE"Login",""COL_RED"You have entered an incorrect password.\n"COL_WHITE"Type your password below to login.","Login","Quit"); | |
| 376 | } | |
| 377 | return 1; | |
| 378 | } | |
| 379 | } | |
| 380 | ||
| 381 | case DIALOG_ADVEHICLES: | |
| 382 | {
| |
| 383 | if(response) | |
| 384 | {
| |
| 385 | - | CreateVehicleForPlayer(playerid, "432", -1, -1, 1000); |
| 385 | + | switch(listitem) |
| 386 | {
| |
| 387 | case 0: | |
| 388 | {
| |
| 389 | - | CreateVehicleForPlayer(playerid, "520", -1, -1, 1000); |
| 389 | + | CreateVehicleForPlayer(playerid, "432", -1, -1, 1000); |
| 390 | } | |
| 391 | case 1: | |
| 392 | {
| |
| 393 | - | CreateVehicleForPlayer(playerid, "470", -1, -1, 1000); |
| 393 | + | CreateVehicleForPlayer(playerid, "520", -1, -1, 1000); |
| 394 | } | |
| 395 | case 2: | |
| 396 | {
| |
| 397 | - | CreateVehicleForPlayer(playerid, "425", -1, -1, 1000); |
| 397 | + | CreateVehicleForPlayer(playerid, "470", -1, -1, 1000); |
| 398 | } | |
| 399 | case 3: | |
| 400 | {
| |
| 401 | - | CreateVehicleForPlayer(playerid, "487", -1, -1, 1000); |
| 401 | + | CreateVehicleForPlayer(playerid, "425", -1, -1, 1000); |
| 402 | } | |
| 403 | case 4: | |
| 404 | {
| |
| 405 | - | CreateVehicleForPlayer(playerid, "601", -1, -1, 1000); |
| 405 | + | CreateVehicleForPlayer(playerid, "487", -1, -1, 1000); |
| 406 | } | |
| 407 | case 5: | |
| 408 | {
| |
| 409 | - | CreateVehicleForPlayer(playerid, "433", -1, -1, 1000); |
| 409 | + | CreateVehicleForPlayer(playerid, "601", -1, -1, 1000); |
| 410 | } | |
| 411 | case 6: | |
| 412 | {
| |
| 413 | - | CreateVehicleForPlayer(playerid, "407", -1, -1, 1000); |
| 413 | + | CreateVehicleForPlayer(playerid, "433", -1, -1, 1000); |
| 414 | } | |
| 415 | case 7: | |
| 416 | {
| |
| 417 | CreateVehicleForPlayer(playerid, "407", -1, -1, 1000); | |
| 418 | } | |
| 419 | } | |
| 420 | } | |
| 421 | } | |
| 422 | else //Line 422 | |
| 423 | {
| |
| 424 | SendClientMessage(playerid, 0xFF0000FF, "You have cancelled!"); | |
| 425 | switch(listitem) | |
| 426 | {
| |
| 427 | case 0: | |
| 428 | {
| |
| 429 | //Selected Item: "Rhino" | |
| 430 | } | |
| 431 | case 1: | |
| 432 | {
| |
| 433 | //Selected Item: "Hydra" | |
| 434 | } | |
| 435 | case 2: | |
| 436 | {
| |
| 437 | //Selected Item: "Patriot" | |
| 438 | } | |
| 439 | case 3: | |
| 440 | {
| |
| 441 | //Selected Item: "Hunter" | |
| 442 | } | |
| 443 | case 4: | |
| 444 | {
| |
| 445 | //Selected Item: "Maverick" | |
| 446 | } | |
| 447 | case 5: | |
| 448 | {
| |
| 449 | //Selected Item: "S.W.A.T. Van" | |
| 450 | } | |
| 451 | case 6: | |
| 452 | {
| |
| 453 | //Selected Item: "Barracks" | |
| 454 | } | |
| 455 | case 7: | |
| 456 | {
| |
| 457 | //Selected Item: "Firetruck" | |
| 458 | } | |
| 459 | } | |
| 460 | } | |
| 461 | } //Line 461 | |
| 462 | return 1; //Line 462 | |
| 463 | } | |
| 464 | ||
| 465 | public OnPlayerClickPlayer(playerid, clickedplayerid, source) | |
| 466 | {
| |
| 467 | return 1; | |
| 468 | } |