Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //| ------------------------------ Bomb System ------------------------------ |
- #include a_samp
- #include dof2
- #define SendFormatMessage(%0,%1,%2) format(String,sizeof(String),%1,%2),SendClientMessage(%0,-1,String)
- #define MINE_COST 100
- #define MAX_MINES 5
- new pName[MAX_PLAYERS][25];
- new g_BombStr[128];
- enum MineInfo
- {
- bool:IsReady,
- bool:Plant,
- Float:Pos[3],
- Mines,
- Mine
- };
- enum MineInfo2
- {
- bool:IsReady,
- bool:Plant,
- Float:Pos[3],
- Mines,
- Mine2
- };
- new PlayerInfo2[MAX_PLAYERS][MineInfo];
- new PlayerInfo[MAX_PLAYERS][MineInfo];
- new Float:Position[3];
- new String[128];
- public OnFilterScriptInit()
- {
- return 1;
- }
- public OnFilterScriptExit()
- {
- DOF2_SaveFile();
- return 1;
- }
- public OnPlayerConnect(playerid)
- {
- GetPlayerName(playerid, pName[playerid], MAX_PLAYER_NAME+1);
- return 1;
- if(!DOF2_FileExists(MFile(playerid))) DOF2_CreateFile(MFile(playerid));
- if(DOF2_GetBool(MFile(playerid), "Plant") == true)
- {
- PlayerInfo[playerid][Plant] = true;
- PlayerInfo[playerid][Pos][0] = DOF2_GetFloat(MFile(playerid), "X");
- PlayerInfo[playerid][Pos][1] = DOF2_GetFloat(MFile(playerid), "Y");
- PlayerInfo[playerid][Pos][2] = DOF2_GetFloat(MFile(playerid), "Z");
- PlayerInfo[playerid][Mine] = CreateObject(3385, PlayerInfo[playerid][Pos][0], PlayerInfo[playerid][Pos][1], PlayerInfo[playerid][Pos][2]-1.0, 0.0, 0.0, 0.0);
- PlayerInfo[playerid][IsReady] = true;
- }
- PlayerInfo[playerid][Mines] = DOF2_GetInt(MFile(playerid), "Mines");
- return 1;
- }
- public OnPlayerDisconnect(playerid, reason)
- {
- DOF2_SetBool(MFile(playerid), "Plant", PlayerInfo[playerid][Plant]);
- DOF2_SetFloat(MFile(playerid), "X", PlayerInfo[playerid][Pos][0]);
- DOF2_SetFloat(MFile(playerid), "Y", PlayerInfo[playerid][Pos][1]);
- DOF2_SetFloat(MFile(playerid), "Z", PlayerInfo[playerid][Pos][2]);
- DOF2_SetInt(MFile(playerid), "Mines", PlayerInfo[playerid][Mines]);
- DestroyObject(PlayerInfo[playerid][Mine]);
- DOF2_SaveFile();
- return 1;
- }
- public OnPlayerCommandText(playerid, cmdtext[])
- {
- new cmd[256], tmp[256], idx;
- cmd = strtok(cmdtext, idx);
- tmp = strtok(cmdtext, idx);
- if(strcmp(cmd, "/Bomb", true) == 0)
- {
- if(!strlen(tmp)) return SendClientMessage(playerid, -1, "/Bomb [Buy | Use | My] :השתמש כך");
- if(!strcmp(tmp, "Buy", true))
- {
- if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, 0xFF0000FF, "! אינך ברכב");
- if(PlayerInfo[playerid][Mines] == MAX_MINES) return SendFormatMessage(playerid, "! לא ניתן לקנות יותר מ %d מוקשים", MAX_MINES);
- if(GetPlayerMoney(playerid) < MINE_COST) return SendFormatMessage(playerid, "$%s :אין לך מספיק כסף, מחיר כל מוקש", GetNum(MINE_COST));
- PlayerInfo[playerid][Mines] ++;
- GivePlayerMoney(playerid, -MINE_COST);
- SendFormatMessage(playerid, "! קנית מוקש בהצלחה, כעת יש לך: %d מוקשים", PlayerInfo[playerid][Mines]);
- return 1;
- }
- else if(!strcmp(tmp, "Use", true))
- {
- if(!IsPlayerInAnyVehicle(playerid))return SendClientMessage(playerid, 0xFF0000FF, "! אינך ברכב");
- if(PlayerInfo[playerid][Plant] == true) return SendClientMessage(playerid, -1, "! הטמנת כבר מוקש");
- if(PlayerInfo[playerid][Mines] == 0) return SendClientMessage(playerid, -1, "! אין לך מוקשים");
- GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
- PlayerInfo2[playerid][Mine2] = CreateObject(3385, Position[0], Position[1], Position[2]-1.0, 0.0, 0.0, 0.0);
- PlayerInfo[playerid][Pos][0] = Position[0];
- PlayerInfo[playerid][Pos][1] = Position[1];
- PlayerInfo[playerid][Pos][2] = Position[2];
- GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
- format(g_BombStr, 128, "!~Bomb~! By:{ffffff} %s", pName[playerid]);
- PlayerInfo[playerid][Mine] = Create3DTextLabel(g_BombStr, 0xFF0000FF, Position[0], Position[1], Position[2], 35.0,0);
- PlayerInfo[playerid][Pos][0] = Position[0];
- PlayerInfo[playerid][Pos][1] = Position[1];
- PlayerInfo[playerid][Pos][2] = Position[2];
- GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
- ApplyAnimation(playerid, "BOMBER", "BOM_Plant", 4.0, 0, 0, 0, 0, 0);
- PlayerInfo[playerid][Plant] = true;
- SendClientMessage(playerid, -1, "! הטמנת מוקש, בהצלחה");
- CountDownMine(playerid, 5);
- return 1;
- }
- else if(!strcmp(tmp, "My", true)) return SendFormatMessage(playerid, "! יש לך כעת: %d מוקשים", PlayerInfo[playerid][Mines]);
- else SendClientMessage(playerid, -1, "/Bomb [Buy | Use | My] :השתמש כך");
- return 1;
- }
- return 0;
- }
- public OnPlayerUpdate(playerid)
- {
- GetPlayerPos(playerid, Position[0], Position[1], Position[2]);
- for(new i = 0; i < GetMaxPlayers(); i++)
- {
- if(IsPlayerInRangeOfPoint(playerid, 2.5, PlayerInfo[i][Pos][0], PlayerInfo[i][Pos][1], PlayerInfo[i][Pos][2]) && PlayerInfo[i][IsReady] == true)
- {
- CreateExplosion(Position[0], Position[1], Position[2], 7, 10);
- DestroyObject(PlayerInfo2[i][Mine2]);
- Delete3DTextLabel(PlayerInfo[i][Mine]);
- PlayerInfo[i][Plant] = false;
- PlayerInfo[i][Pos][0] = 0;
- PlayerInfo[i][Pos][1] = 0;
- PlayerInfo[i][Pos][2] = 0;
- PlayerInfo[i][Mines] --;
- PlayerInfo[i][IsReady] = false;
- }
- }
- return 1;
- }
- forward CountDownMine(playerid, Sec);
- public CountDownMine(playerid, Sec)
- {
- if(Sec == 0)
- {
- GameTextForPlayer(playerid, "The Bomb Is Ready", 3000, 3);
- PlayerPlaySound(playerid, 1057, 0.0, 0.0, 0.0);
- PlayerInfo[playerid][IsReady] = true;
- return 1;
- }
- format(String, sizeof(String), "~g~%d", Sec);
- GameTextForPlayer(playerid, String, 1000, 4);
- PlayerPlaySound(playerid, 1058, 0.0, 0.0, 0.0);
- SetTimerEx("CountDownMine", 1000, false, "%d", playerid, Sec-1);
- return 1;
- }
- stock strtok(const Str[], &index)
- {
- new length = strlen(Str);
- while ((index < length) && (Str[index] <= ' '))
- {
- index++;
- }
- new offset = index;
- new result[20];
- while ((index < length) && (Str[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
- {
- result[index - offset] = Str[index];
- index++;
- }
- result[index - offset] = EOS;
- return result;
- }
- stock GetNum(num)
- {
- new string[64];
- format(string, sizeof(string), "%d", num);
- for(new idx = strlen(string) % 3 == 0 ? 3 : strlen(string) % 3; idx < strlen(string); idx += 4) strins(string, ",", idx);
- return string;
- }
- stock MFile(playerid)
- {
- new File[MAX_PLAYER_NAME+1], PName[MAX_PLAYER_NAME+1];
- GetPlayerName(playerid, PName, sizeof(PName));
- format(File, sizeof(File), "Bomb/%s.ini", PName);
- return File;
- }
- //------------------------------------------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement