20.11.2013, 15:50
PHP код:
CMD:hwithdraw(playerid, params[])
{
new string[128], option[32], amount;
new idx = PlayerInfo[playerid][pHouse];
if(!IsPlayerLoggedIn(playerid)) return SendClientMessage(playerid, COLOR_GREY, "You need to login first before using any command.");
if(!PlayerInfo[playerid][pHouse] && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You don't own a house.");
if(GetPlayerVirtualWorld(playerid)-500 != idx && !PlayerInfo[playerid][pVHouse]) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
if(GetPlayerVirtualWorld(playerid)-500 != idx && PlayerInfo[playerid][pVHouse])
{
idx = PlayerInfo[playerid][pVHouse];
if(GetPlayerVirtualWorld(playerid)-500 != idx) return SendClientMessage(playerid, COLOR_GREY, "You are not inside your house.");
}
if(sscanf(params, "s[32]", option))
{
SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /hsafe withdraw [item]");
SendClientMessage(playerid, COLOR_GREY, "Items: 1) money | 2) weapon | 3) weed | 4) cocaine");
format(string, sizeof(string), "SAFE: $%d | %d Weed | %d cocaine", HouseInfo[idx][hMoney], HouseInfo[idx][hWeed], HouseInfo[idx][hcocaine]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "SAFE: Weapon 1: %s (%d Ammo) | Weapon 2: %s (%d Ammo) | Weapon 3: %s (%d Ammo)", RWN(HouseInfo[idx][hGun][0]), HouseInfo[idx][hGunAmmo][0], RWN(HouseInfo[idx][hGun][1]), HouseInfo[idx][hGunAmmo][1], RWN(HouseInfo[idx][hGun][2]), HouseInfo[idx][hGunAmmo][2]);
SendClientMessage(playerid, COLOR_WHITE, string);
format(string, sizeof(string), "SAFE: Weapon 4: %s (%d Ammo) | Weapon 5: %s (%d Ammo)", RWN(HouseInfo[idx][hGun][3]), HouseInfo[idx][hGunAmmo][3], RWN(HouseInfo[idx][hGun][4]), HouseInfo[idx][hGunAmmo][4]);
SendClientMessage(playerid, COLOR_WHITE, string);
return 1;
}
if(!strcmp(option, "money", true, 5))
{
if(sscanf(params, "s[32]i", option, amount)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /hsafe withdraw money [amount]");
if(HouseInfo[idx][hMoney] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much money in your house vault.");
HouseInfo[idx][hMoney] -= amount;
GiveDodMoney(playerid, amount);
format(string, sizeof(string), "* %s opens their vault, takes $%d and closes it.", RPN(playerid), amount);
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
else if(!strcmp(option, "weapon", true, 4))
{
if(sscanf(params, "s[32]i", option, amount)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /hsafe withdraw weapon [slot]");
if(amount < 1 || amount > 5) return SendClientMessage(playerid, COLOR_GREY, "Weapon slots are between 1 and 5.");
amount = amount-1;
if(!HouseInfo[idx][hGun][amount]) return SendClientMessage(playerid, COLOR_GREY, "You don't have a weapon in this slot.");
GiveDodWeapon(playerid, HouseInfo[idx][hGun][amount], HouseInfo[idx][hGunAmmo][amount]);
format(string, sizeof(string), "* %s opens their vault, takes a %s closes it.", RPN(playerid), RWN(HouseInfo[idx][hGun][amount]));
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
HouseInfo[idx][hGun][amount] = 0;
HouseInfo[idx][hGunAmmo][amount] = 0;
}
else if(!strcmp(option, "weed", true, 4))
{
if(sscanf(params, "s[32]i", option, amount)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /hsafe withdraw weed [amount]");
if(HouseInfo[idx][hWeed] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much weed in your house vault.");
HouseInfo[idx][hWeed] -= amount;
PlayerInfo[playerid][pWeed] += amount;
format(string, sizeof(string), "* %s opens their vault, takes %d grams of weed and closes it.", RPN(playerid), amount);
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
else if(!strcmp(option, "cocaine", true, 4))
{
if(sscanf(params, "s[32]i", option, amount)) return SendClientMessage(playerid, COLOR_WHITE, "[Usage]: /hsafe withdraw cocaine [amount]");
if(HouseInfo[idx][hcocaine] < amount) return SendClientMessage(playerid, COLOR_GREY, "You don't have that much cocaine in your house vault.");
HouseInfo[idx][hcocaine] -= amount;
PlayerInfo[playerid][pcocaine] += amount;
format(string, sizeof(string), "* %s opens their vault, takes %d grams of cocaine and closes it.", RPN(playerid), amount);
SendNearbyMessage(playerid, 15, string, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE, COLOR_PURPLE);
}
return 1;
}
/hwithdraw money [you got ? Money]