09.02.2013, 18:50
Since I found it from a 3 year old topic i cant provide you with any arrays, but if you have some scripting knowledge you can pull this off by yourself.
I didn't create it, just poiting you in the right direction
I didn't create it, just poiting you in the right direction
Код:
if (strcmp(cmd, "/housesafe", true) == 0) { if(IsPlayerConnected(playerid)) { new house = PlayerInfo[playerid][pCribKey]; new safe = (GetPlayerVirtualWorld(playerid) - 50); GetPlayerName(playerid, playername, sizeof(playername)); if (safe < 0) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " There is no house safe here!"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Usage: /housesafe (deposit/withdraw/open/close/rekey)"); return 1; } if(strcmp(tmp,"open",true) == 0) { if (CribInfo[safe][hSafeStatus] == 1) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " The safe is already open!"); return 1; } new combo1,combo2,combo3; tmp = strtok(cmdtext, idx); combo1 = strvalEx(tmp); tmp = strtok(cmdtext, idx); combo2 = strvalEx(tmp); tmp = strtok(cmdtext, idx); combo3 = strvalEx(tmp); if (combo1 != CribInfo[safe][hSafeCombo1] || combo2 != CribInfo[safe][hSafeCombo2] || combo3 != CribInfo[safe][hSafeCombo3]) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Invalid combination."); return 1; } CribInfo[safe][hSafeStatus] = 1; SendClientMessage(playerid, COLOR_LIGHTBLUE, " Viola! The safe is open!"); } else if(strcmp(tmp,"close",true) == 0) { if (CribInfo[safe][hSafeStatus] == 0) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " The safe is already closed!"); return 1; } CribInfo[safe][hSafeStatus] = 0; SendClientMessage(playerid, COLOR_LIGHTBLUE, " Safe has been closed!"); } else if(strcmp(tmp,"rekey",true) == 0) { if (house != 9999 && strcmp(playername, CribInfo[PlayerInfo[playerid][pCribKey]][hOwner], true) == 0) { new combo1,combo2,combo3; tmp = strtok(cmdtext, idx); combo1 = strvalEx(tmp); tmp = strtok(cmdtext, idx); combo2 = strvalEx(tmp); tmp = strtok(cmdtext, idx); combo3 = strvalEx(tmp); if (combo1 > 999999 || combo2 > 999999 || combo3 > 999999 || combo1 < 1 || combo2 < 1 || combo3 < 1) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Invalid combination. (1-999999)"); return 1; } if (PlayerInfo[playerid][pCribKey] != safe) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Nice try! FAIL! Pwnd by Krayzie Jackson."); return 1; } CribInfo[safe][hSafeCombo1] = combo1; CribInfo[safe][hSafeCombo2] = combo2; CribInfo[safe][hSafeCombo3] = combo3; SendClientMessage(playerid, COLOR_LIGHTBLUE, " Safe combination changed! Don't forget it!"); return 1; } else { SendClientMessage(playerid, COLOR_LIGHTBLUE, " You must be the house owner to re-key a safe!"); return 1; } } else if(strcmp(tmp,"deposit",true) == 0) { if (CribInfo[safe][hSafeStatus] == 0) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " The safe is closed!"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Usage: /housesafe deposit (money/materials/drugs/gun/contents)"); return 1; } if(strcmp(tmp,"drugs",true) == 0) { new cashdeposit; tmp = strtok(cmdtext, idx); cashdeposit = strvalEx(tmp); new droppername[MAX_PLAYER_NAME]; GetPlayerName(playerid, droppername, sizeof(droppername)); if(cashdeposit <= 0) return 1; if(cashdeposit > PlayerInfo[playerid][pDrugs]) { SendClientMessage(playerid, COLOR_GREY, " You dont have that many drugs with you!"); return 1; } PlayerInfo[playerid][pDrugs] -= cashdeposit; CribInfo[safe][hSafeDrugs] += cashdeposit; OnPropUpdate(); format(string, sizeof(string), "%s places some drugs in a safe.", droppername); ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); printf("%s", string); return 1; } else if(strcmp(tmp,"money",true) == 0) { new cashdeposit; new droppername[MAX_PLAYER_NAME]; GetPlayerName(playerid, droppername, sizeof(droppername)); tmp = strtok(cmdtext, idx); cashdeposit = strvalEx(tmp); if(cashdeposit <= 0) return 1; if(cashdeposit > GetPlayerMoneyKrayzie(playerid)) { SendClientMessage(playerid, COLOR_GREY, "You dont have that much money with you!"); return 1; } GivePlayerMoneyKrayzie(playerid,-cashdeposit); CribInfo[safe][hSafeCash] += cashdeposit; OnPropUpdate(); format(string, sizeof(string), "%s drops some cash in a safe.", droppername); ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); printf("%s", string); return 1; } else if(strcmp(tmp,"materials",true) == 0) { new cashdeposit; new droppername[MAX_PLAYER_NAME]; GetPlayerName(playerid, droppername, sizeof(droppername)); tmp = strtok(cmdtext, idx); cashdeposit = strvalEx(tmp); if(cashdeposit <= 0) return 1; if(cashdeposit > PlayerInfo[playerid][pMats]) { SendClientMessage(playerid, COLOR_GREY, " You dont have that many materials with you!"); return 1; } PlayerInfo[playerid][pMats] -= cashdeposit; CribInfo[safe][hSafeMats] += cashdeposit; OnPropUpdate(); format(string, sizeof(string), "%s drops some materials in a safe.", droppername); ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); printf("%s", string); return 1; } else if(strcmp(tmp,"gun",true) == 0) { new cashdeposit; new droppername[MAX_PLAYER_NAME]; GetPlayerName(playerid, droppername, sizeof(droppername)); tmp = strtok(cmdtext, idx); cashdeposit = strvalEx(tmp); if(cashdeposit <= 0) return 1; new ammo,weap; new found = 0; new gunammo = 0; for (new slot = 0; slot < 14; slot++) { GetPlayerWeaponData(playerid, slot,weap,ammo); if (weap == cashdeposit) { found = 1; gunammo = ammo; format(string, sizeof(string), "A %s has been found with %d ammo.", GunNames[weap],ammo); SendClientMessage(playerid, COLOR_WHITE, string); } } if(found == 0) { SendClientMessage(playerid, COLOR_GREY, " You don't have that gun in your posession!"); return 1; } // make sure they have enough room in the safe new gunsinsafe = 0; new maxguns = 0; if(CribInfo[safe][hGunSafe1] > 0) gunsinsafe++; if(CribInfo[safe][hGunSafe2] > 0) gunsinsafe++; if(CribInfo[safe][hGunSafe3] > 0) gunsinsafe++; if(CribInfo[safe][hGunSafe4] > 0) gunsinsafe++; if(CribInfo[safe][hSafeLevel] == 1) { SendClientMessage(playerid, COLOR_GREY, " You dont have enough room to store that gun! Upgrade your safe."); return 1; } else if(CribInfo[safe][hSafeLevel] == 2) maxguns = 1; else if(CribInfo[safe][hSafeLevel] == 3) maxguns = 2; else if(CribInfo[safe][hSafeLevel] == 4) maxguns = 3; else if(CribInfo[safe][hSafeLevel] == 5) maxguns = 4; if (gunsinsafe == maxguns) { SendClientMessage(playerid, COLOR_GREY, " You dont have enough room to store that gun! Upgrade your safe."); return 1; } GivePlayerWeapon(playerid,cashdeposit,-gunammo); if (gunsinsafe == 0) { CribInfo[safe][hGunSafe1] = cashdeposit; CribInfo[safe][hGunAmmo1] = gunammo; } else if (gunsinsafe == 1) { CribInfo[safe][hGunSafe2] = cashdeposit; CribInfo[safe][hGunAmmo2] = gunammo; } else if (gunsinsafe == 2) { CribInfo[safe][hGunSafe3] = cashdeposit; CribInfo[safe][hGunAmmo3] = gunammo; } else if (gunsinsafe == 3) { CribInfo[safe][hGunSafe4] = cashdeposit; CribInfo[safe][hGunAmmo4] = gunammo; } OnPropUpdate(); format(string, sizeof(string), "%s drops a firearm in a safe.", droppername); ProxDetector(20.0, playerid, string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5); printf("%s", string); return 1; } else if(strcmp(tmp,"info",true) == 0) { format(string, sizeof(string), "Cash: %d Materials: %d Drugs: %d", CribInfo[safe][hSafeDrugs],CribInfo[safe][hSafeMats],CribInfo[safe][hSafeCash]); SendClientMessage(playerid, COLOR_LIGHTBLUE, string); return 1; } else { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Invalid selection!"); return 1; } } else if(strcmp(tmp,"withdraw",true) == 0) { if (CribInfo[safe][hSafeStatus] == 0) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " The safe is closed!"); return 1; } tmp = strtok(cmdtext, idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Usage: /housesafe withdraw (money/materials/drugs/gun/contents)"); return 1; } if(strcmp(tmp,"drugs",true) == 0) { new cashdeposit; tmp = strtok(cmdtext, idx); cashdeposit = strvalEx(tmp); if(cashdeposit < 0) return 1; if(cashdeposit > CribInfo[safe][hSafeDrugs]) { SendClientMessage(playerid, COLOR_GREY, "You dont have that many drugs in the safe!"); return 1; } if (PlayerInfo[playerid][pDrugs] + cashdeposit > 100) { SendClientMessage(playerid, COLOR_GREY, "You can't carry that many drugs!"); return 1; } PlayerInfo[playerid][pDrugs] += cashdeposit; CribInfo[safe][hSafeDrugs] -= cashdeposit; SendClientMessage(playerid, COLOR_GREY, "You get some drugs from the safe."); OnPropUpdate(); return 1; } else if(strcmp(tmp,"money",true) == 0) { new cashdeposit; tmp = strtok(cmdtext, idx); cashdeposit = strvalEx(tmp); if(cashdeposit < 0) return 1; if(cashdeposit > CribInfo[safe][hSafeCash]) { SendClientMessage(playerid, COLOR_GREY, "You dont have that much money in the safe!"); return 1; } GivePlayerMoneyKrayzie(playerid,cashdeposit); CribInfo[safe][hSafeCash] -= cashdeposit; ConsumingMoney[playerid] = 1; SendClientMessage(playerid, COLOR_GREY, "You get some money from the safe."); OnPropUpdate(); return 1; } else if(strcmp(tmp,"materials",true) == 0) { new cashdeposit; tmp = strtok(cmdtext, idx); cashdeposit = strvalEx(tmp); if(cashdeposit < 0) return 1; if(cashdeposit > CribInfo[safe][hSafeMats]) { SendClientMessage(playerid, COLOR_GREY, "You dont have that many materials in the safe!"); return 1; } PlayerInfo[playerid][pMats] += cashdeposit; CribInfo[safe][hSafeMats] -= cashdeposit; SendClientMessage(playerid, COLOR_GREY, "You get some materials from the safe."); OnPropUpdate(); return 1; } else if(strcmp(tmp,"gun",true) == 0) { new cashdeposit; tmp = strtok(cmdtext, idx); cashdeposit = strvalEx(tmp); if(cashdeposit <= 0) return 1; if (cashdeposit == 1) { if (CribInfo[safe][hGunSafe1] == 0) { SendClientMessage(playerid, COLOR_GREY, "You dont have a gun in that slot!"); return 1; } GivePlayerWeapon(playerid,CribInfo[safe][hGunSafe1],CribInfo[safe][hGunAmmo1]); CribInfo[safe][hGunSafe1] = 0; CribInfo[safe][hGunAmmo1] = 0; } if (cashdeposit == 2) { if (CribInfo[safe][hGunSafe2] == 0) { SendClientMessage(playerid, COLOR_GREY, "You dont have a gun in that slot!"); return 1; } GivePlayerWeapon(playerid,CribInfo[safe][hGunSafe2],CribInfo[safe][hGunAmmo2]); CribInfo[safe][hGunSafe2] = 0; CribInfo[safe][hGunAmmo2] = 0; } if (cashdeposit == 3) { if (CribInfo[safe][hGunSafe3] == 0) { SendClientMessage(playerid, COLOR_GREY, "You dont have a gun in that slot!"); return 1; } GivePlayerWeapon(playerid,CribInfo[safe][hGunSafe3],CribInfo[safe][hGunAmmo3]); CribInfo[safe][hGunSafe3] = 0; CribInfo[safe][hGunAmmo3] = 0; } if (cashdeposit == 4) { if (CribInfo[safe][hGunSafe4] == 0) { SendClientMessage(playerid, COLOR_GREY, "You dont have a gun in that slot!"); return 1; } GivePlayerWeapon(playerid,CribInfo[safe][hGunSafe4],CribInfo[safe][hGunAmmo4]); CribInfo[safe][hGunSafe4] = 0; CribInfo[safe][hGunAmmo4] = 0; } SendClientMessage(playerid, COLOR_GREY, "You get a gun from the safe."); return 1; } else { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Usage: /housesafe withdraw (money/materials/drugs/gun/contents)"); return 1; } } else if(strcmp(tmp,"contents",true) == 0) { if (CribInfo[safe][hSafeStatus] == 0) { SendClientMessage(playerid, COLOR_LIGHTBLUE, " The safe is closed!"); return 1; } SendClientMessage(playerid, COLOR_WHITE, "|__________SAFE CONTENTS__________|"); format(string, sizeof(string), "| Money: %d | Materials: %d | Drugs: %d", CribInfo[safe][hSafeCash],CribInfo[safe][hSafeMats],CribInfo[safe][hSafeDrugs]); SendClientMessage(playerid, COLOR_WHITE, string); new ammo,weap; weap = CribInfo[safe][hGunSafe1]; if (weap > 0) { format(string, sizeof(string), "| Gun Slot 1: %s | Ammo: %d", GunNames[weap],CribInfo[safe][hGunAmmo1]); SendClientMessage(playerid, COLOR_WHITE, string); } else { format(string, sizeof(string), "| Gun Slot 1: Unused | Ammo: None"); SendClientMessage(playerid, COLOR_WHITE, string); } weap = CribInfo[safe][hGunSafe2]; if (weap > 0) { format(string, sizeof(string), "| Gun Slot 2: %s | Ammo: %d", GunNames[weap],CribInfo[safe][hGunAmmo2]); SendClientMessage(playerid, COLOR_WHITE, string); } else { format(string, sizeof(string), "| Gun Slot 2: Unused | Ammo: None"); SendClientMessage(playerid, COLOR_WHITE, string); } weap = CribInfo[safe][hGunSafe3]; if (weap > 0) { format(string, sizeof(string), "| Gun Slot 3: %s | Ammo: %d", GunNames[weap],CribInfo[safe][hGunAmmo3]); SendClientMessage(playerid, COLOR_WHITE, string); } else { format(string, sizeof(string), "| Gun Slot 3: Unused | Ammo: None"); SendClientMessage(playerid, COLOR_WHITE, string); } weap = CribInfo[safe][hGunSafe4]; if (weap > 0) { format(string, sizeof(string), "| Gun Slot 4: %s | Ammo: %d", GunNames[weap],CribInfo[safe][hGunAmmo4]); SendClientMessage(playerid, COLOR_WHITE, string); } else { format(string, sizeof(string), "| Gun Slot 4: Unused | Ammo: None"); SendClientMessage(playerid, COLOR_WHITE, string); } } else { SendClientMessage(playerid, COLOR_LIGHTBLUE, " Usage: /housesafe (deposit/withdraw/open/close/rekey)"); return 1; } } return 1; }