Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //============================================================================//
- #include < a_samp >
- #include < sscanf2 >
- #include < zcmd >
- #include < foreach >
- //============================================================================//
- #define SCM SendClientMessage
- #define SCMALL SendClientMessageToAll
- #define COLOR_GREY 0xD4D4D4FF
- //DIALOGS DEFINE
- #define DIALOG_DUEL_WEAPON 1
- #define DIALOG_DUEL_MAP 2
- #define DIALOG_DUEL_BET 3
- #define DIALOG_DUEL_INVITE 4
- //============================================================================//
- new InDuel[MAX_PLAYERS],
- DuelInvite[MAX_PLAYERS],
- DuelAccepter[MAX_PLAYERS],
- DuelWeapon[MAX_PLAYERS],
- DuelMap[MAX_PLAYERS],
- DuelBet[MAX_PLAYERS];
- #pragma dynamic 145000
- //============================================================================//
- IsNumeric(const string[])
- {
- for (new i = 0, j = strlen(string); i < j; i++)
- {
- if (string[i] > '9' || string[i] < '0') return 0;
- }
- return 1;
- }
- FormatNumber(number)
- {
- new numOfPeriods = 0, tmp = number;
- new str[32];
- while(tmp > 1000) {
- tmp = floatround(tmp / 1000, floatround_floor), ++numOfPeriods;
- }
- valstr(str, number);
- new slen = strlen(str);
- for(new i = 1; i != numOfPeriods + 1; ++i) {
- strins(str, ",", slen - 3*i);
- }
- return str;
- }
- stock GetName(playerid)
- {
- new szName[MAX_PLAYER_NAME];
- GetPlayerName(playerid, szName, sizeof(szName));
- return szName;
- }
- //============================================================================//
- main(){printf("Gamemode-ul se proceseaza...");}
- forward resetDuel(playerid);
- public resetDuel(playerid)
- {
- InDuel[playerid] = 0;
- DuelInvite[playerid] = -1;
- DuelWeapon[playerid] = -1;
- DuelMap[playerid] = -1;
- DuelAccepter[playerid] = -1;
- return true;
- }
- forward duelTimer(playerid);
- public duelTimer(playerid)
- {
- TogglePlayerControllable(playerid, 1);
- TogglePlayerControllable(DuelInvite[playerid], 1);
- TogglePlayerControllable(DuelAccepter[playerid], 1);
- }
- public OnGameModeInit()
- {
- SetGameModeText("Gamemode Pentru Teste");
- AddPlayerClass(0, 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
- return 1;
- }
- public OnPlayerRequestClass(playerid, classid)
- {
- SetPlayerPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraPos(playerid, 1958.3783, 1343.1572, 15.3746);
- SetPlayerCameraLookAt(playerid, 1958.3783, 1343.1572, 15.3746);
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- resetDuel(playerid);
- GivePlayerMoney(playerid, 500000);
- SetSpawnInfo(playerid, 23, 23, 1954.1691, 1343.0311, 15.3712, 90, 0,0,0,0,0,0);
- return 1;
- }
- public OnPlayerDeath(playerid, killerid, reason)
- {
- if(InDuel[playerid] == 1)
- {
- SpawnPlayer(playerid);
- SetPlayerInterior(playerid, 0);
- GameTextForPlayer(playerid, "You have lost the duel.", 3000, 3);
- GivePlayerMoney(playerid, -DuelBet[playerid]), SCM(playerid, 0xFF7A7AAA, "You have lost the duel and the money");
- resetDuel(playerid);
- }
- if(InDuel[killerid] == 1 && killerid != INVALID_PLAYER_ID)
- {
- SpawnPlayer(killerid);
- SetPlayerInterior(killerid, 0);
- GameTextForPlayer(killerid, "You have won the duel.", 3000, 3);
- GivePlayerMoney(killerid, DuelBet[playerid]);
- SCM(killerid, 0x88FF7AAA, "You have won the duel and the money");
- ResetPlayerWeapons(killerid);
- resetDuel(killerid);
- }
- return 1;
- }
- public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
- {
- switch(dialogid)
- {
- case DIALOG_DUEL_BET:
- {
- if(!response) return resetDuel(playerid);
- else
- {
- if(!IsNumeric(inputtext)) return ShowPlayerDialog(playerid, DIALOG_DUEL_BET, DIALOG_STYLE_INPUT, "Duel System [Bet Select]", "Insert bet amount for duel.\n(bet amount must be > $0 and < $100,000", "Select", "");
- if(strval(inputtext) < 0 || strval(inputtext) > 100000) return ShowPlayerDialog(playerid, DIALOG_DUEL_BET, DIALOG_STYLE_INPUT, "Duel System [Bet Select]", "Insert bet amount for duel.\n(bet amount must be > $0 and < $100,000", "Select", "");
- if(GetPlayerMoney(playerid) < strval(inputtext)) return ShowPlayerDialog(playerid, DIALOG_DUEL_BET, DIALOG_STYLE_INPUT, "Duel System [Bet Select]", "You don't have the amount inserted.\nInsert bet amount for duel.\n(bet amount must be > $0 and < $100,000", "Select", "");
- DuelBet[playerid] = strval(inputtext);
- ShowPlayerDialog(playerid, DIALOG_DUEL_WEAPON, DIALOG_STYLE_LIST, "Duel System [Weapon Select]",
- "Desert Eagle\nM4\nShotgun\nMP5\nSniper", "Select", "");
- }
- }
- case DIALOG_DUEL_MAP:
- {
- if(!response) return resetDuel(playerid);
- switch(listitem)
- {
- case 0: DuelMap[playerid] = 0;
- case 1: DuelMap[playerid] = 1;
- case 2: DuelMap[playerid] = 2;
- }
- new map[56], weapon[56], string[256];
- switch(DuelMap[playerid])
- {
- case 0: format(map, 56, "Chilliad");
- case 1: format(map, 56, "Ammunation");
- case 2: format(map, 56, "Warehouse");
- }
- switch(DuelWeapon[playerid])
- {
- case 0: format(weapon, 56, "Desert Eagle");
- case 1: format(weapon, 56, "M4");
- case 2: format(weapon, 56, "Shotgun");
- case 3: format(weapon, 56, "MP5");
- case 4: format(weapon, 56, "Sniper");
- }
- format(string, sizeof(string), "Duel Invitation sent to: {87ff3d}%s (%d){ffe4a3} | Bet: {87ff3d}%s{ffe4a3} | Weapon: {87ff3d}%s{ffe4a3} | Map: {87ff3d}%s ", GetName(DuelAccepter[playerid]), DuelAccepter[playerid], FormatNumber(DuelBet[playerid]), weapon, map);
- SCM(playerid, 0xffe4a3AA, string);
- format(string, sizeof(string), "{ffe4a3}Duel Invitation from: {87ff3d}%s (%d){ffe4a3}\nBet Amount: {87ff3d}%s{ffe4a3}\nMap: {87ff3d}%s{ffe4a3}\nWeapon: {87ff3d}%s", GetName(playerid), playerid, FormatNumber(DuelBet[playerid]), map, weapon);
- ShowPlayerDialog(DuelAccepter[playerid], DIALOG_DUEL_INVITE, DIALOG_STYLE_MSGBOX, "Duel System [Invitation]", string, "Accept", "Cancel");
- }
- case DIALOG_DUEL_INVITE:
- {
- if(!response) return resetDuel(playerid);
- else
- {
- new userid = DuelInvite[playerid];
- TogglePlayerControllable(playerid, 0);
- TogglePlayerControllable(userid, 0);
- SetTimer("duelTimer", 4000, false);
- GameTextForPlayer(playerid, "BATTLE IS STARTING...", 3000, 3);
- GameTextForPlayer(userid, "BATTLE IS STARTING...", 3000, 3);
- switch(DuelWeapon[userid])
- {
- case 0:
- {
- GivePlayerWeapon(playerid, WEAPON_DEAGLE, 1337);
- GivePlayerWeapon(DuelInvite[playerid], WEAPON_DEAGLE, 1337);
- }
- case 1:
- {
- GivePlayerWeapon(playerid, WEAPON_M4, 1337);
- GivePlayerWeapon(DuelInvite[playerid], WEAPON_M4, 1337);
- }
- case 2:
- {
- GivePlayerWeapon(playerid, WEAPON_SHOTGUN, 1337);
- GivePlayerWeapon(DuelInvite[playerid], WEAPON_SHOTGUN, 1337);
- }
- case 3:
- {
- GivePlayerWeapon(playerid, WEAPON_MP5, 1337);
- GivePlayerWeapon(DuelInvite[playerid], WEAPON_MP5, 1337);
- }
- case 4:
- {
- GivePlayerWeapon(playerid, WEAPON_SNIPER, 1337);
- GivePlayerWeapon(DuelInvite[playerid], WEAPON_SNIPER, 1337);
- }
- }
- switch(DuelMap[userid])
- {
- case 0:
- {
- SetPlayerPos(playerid, -2319.5796, -1636.9464, 483.7679);
- SetPlayerPos(DuelInvite[playerid], -2324.5034, -1623.0521, 483.7335);
- }
- case 1:
- {
- SetPlayerInterior(playerid, 7);
- SetPlayerPos(playerid, 293.5793, -134.6942, 1004.1299);
- SetPlayerInterior(DuelInvite[playerid], 7);
- SetPlayerPos(DuelInvite[playerid], 283.1079, -134.7406, 1004.0901);
- }
- case 2:
- {
- SetPlayerPos(playerid, 1399.5500, -19.3916, 1000.9594);
- SetPlayerPos(DuelInvite[playerid], 1383.6892, -19.3346, 1000.9594);
- SetPlayerInterior(playerid, 1);
- SetPlayerInterior(DuelInvite[playerid], 1);
- }
- }
- SetPlayerHealth(playerid, 100);
- SetPlayerHealth(userid, 100);
- SetPlayerArmour(playerid, 100);
- SetPlayerArmour(userid, 100);
- InDuel[playerid] = 1;
- InDuel[userid] = 1;
- }
- }
- case DIALOG_DUEL_WEAPON:
- {
- if(!response) return 1;
- switch(listitem)
- {
- case 0:
- {
- DuelWeapon[playerid] = 0;
- ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
- }
- case 1:
- {
- DuelWeapon[playerid] = 1;
- ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
- }
- case 2:
- {
- DuelWeapon[playerid] = 2;
- ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
- }
- case 3:
- {
- DuelWeapon[playerid] = 3;
- ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
- }
- case 4:
- {
- DuelWeapon[playerid] = 4;
- ShowPlayerDialog(playerid, DIALOG_DUEL_MAP, DIALOG_STYLE_LIST, "Duel System [Map Select]", "Chilliad\nAmmunation Range\nWarehouse", "Select", "");
- }
- }
- }
- }
- return 1;
- }
- //Comenzi_Publice
- //Duel_System
- CMD:duel(playerid, params[])
- {
- if(InDuel[playerid] == 1) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}You are already in a duel.");
- new userid;
- if(sscanf(params, "u", userid)) return SCM(playerid, COLOR_GREY, "Usage: {FFFFFF}/duel <playerid>");
- if(userid == INVALID_PLAYER_ID) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}Player is not connected.");
- DuelInvite[userid] = playerid;
- DuelAccepter[playerid] = userid;
- if(InDuel[userid] == 1) return SCM(playerid, COLOR_GREY, "Error: {FFFFFF}Player is already in a duel.");
- ShowPlayerDialog(playerid, DIALOG_DUEL_BET, DIALOG_STYLE_INPUT, "Duel System [Bet Select]", "Insert bet amount for duel.\n(bet amount must be > $0 and < $100,000", "Select", "");
- return 1;
- }
Add Comment
Please, Sign In to add comment