po ovome sam radio = http://forum.sa-mp.com/showthread.php?t=149416
pomoc.
ako bas zelite code da vidite evo vam.
#include
#define MAX_BUSINESSES 100 //Increase if you need more but it will make your script larger.
#define PayoutTimer 60 //Number of seconds before the player gets his next pay.
enum BiznisInfo
{
Float:BiznisX, //Business X Pos
Float:BiznisY, //Business Y Pos
Float:BiznisZ, //Business Z Pos
BiznisCijena, //Business buy cost
BiznisProdaja, // Business sell cost
BiznisZarada, //Business earn
BiznisVlasnik, // ID of the player that owns the business
BiznisIme, // The name of the business
Disabled //If the business is disabled or not
};
//Add these at the top of your script.
new BusinessPickup; // This is for all the pickups for the businesses.
new BusinessCount = -1; // This is so we can store all the business info like this BusinessInfo[]
new BusinessInfo; // All the enum info is saved into one variable.
CreateBusiness(cuisine[])//, Float:XPos, Float:YPos, Float:ZPos, Price, Sell, Earn
{
if(!strlen(cuisine)) return 0; //If there is no name then it will not create the business
BusinessCount ++; //Adding 1 onto the businesscount so the first one will be BusinessInfo[....]
BusinessInfo = 2267.62792969; //Sets the Xpos into the variable for long term saving.
BusinessInfo = -1670.58251953; //Sets the Ypos into the variable for long term saving.
BusinessInfo = 15.77589893; //Sets the Zpos into the variable for long term saving.
BusinessInfo = 100; //Sets the price into the variable for long term saving.
BusinessInfo = 100; //Sets the Sell cost into the variable for long term saving.
BusinessInfo = 100; // //Sets the earning into the variable for long term saving.
BusinessInfo = -1; //Sets the business owner into the variable for long term saving.
BusinessPickup = AddStaticPickup(1272, 19, 2267.62792969,-1670.58251953,15.77589893, -1); //Adds the pickup
format(BusinessInfo, 60, "%s", cuisine); //Sets the business name into the variable for long term saving.
SetTimer("OnPlayerPickUpPickup", 1, true);
return BusinessCount; //Will return the business ID
}
public OnFilterScriptInit() //Change to OnFilterScriptInit if it's a filterscript =].
{
SetTimer("Payouttimer", 10000, true); //Sets the timer =].
//CreateBusiness("TesBiznis", 100.0, 100.0, 10.0, 13337, 10000, 100);
CreateBusiness("cuisine");
return 1;
}
stock IsPlayerCloseEnoughToBis(playerid)
{
for(new C; C {
if(IsPlayerInRangeOfPoint(playerid, 3, BusinessInfo, BusinessInfo, BusinessInfo)) return C; // Checks if a business is close enough
}
return -1;
}
forward Payouttimer(); //You must forward a timer
public Payouttimer()
{
for(new i; i {
if(GetPVarInt(i, "Businessearnings") != 0) //Does the player earn any $$
{
new Str; // Creating a string
format(Str, sizeof(Str), "You have earned %d from all your properties!", GetPVarInt(i, "Businessearnings")); //Formats the string
SendClientMessage(i, 0x00FF00AA, Str); //Sends the string to the player
GivePlayerMoney(i, GetPVarInt(i, "Businessearnings")); //Gives the player the $$
}
}
return 1;
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if(!strcmp(cmdtext, "/buy", true))
{
if(IsPlayerCloseEnoughToBis(playerid) == -1) return SendClientMessage(playerid, 0xAA3333AA, "Niste dovoljno blizu biznisa!!!"); //Returns this if the player isn't within 3 X, Y or Z of the business
new buss = IsPlayerCloseEnoughToBis(playerid); //Makes a shorter define
if(BusinessInfo == 1) return SendClientMessage(playerid, 0xAA3333AA, "biznis je onesposobljen!!"); //This is for a function down at the bottom of this tutorial
if(GetPlayerMoney(playerid) < BusinessInfo) return SendClientMessage(playerid, 0xAA3333AA, "Nemate dovoljno novca za ovaj biznis."); //Will return this if the player is a poor nub =D.
if(BusinessInfo != -1) return SendClientMessage(playerid, 0xAA3333AA, "Netko vec posjeduje ovaj biznis!"); //Will return it if somebody online owns the business.
BusinessInfo = playerid; //Sets the business owner
SetPVarInt(playerid, "Businessearnings" , GetPVarInt(playerid, "Businessearnings") + BusinessInfo); // Makes the players earn more
new str; //Creates a string
format(str, sizeof(str), "You have brought the business %s for $%d. You will now earn $%d", BusinessInfo, BusinessInfo, BusinessInfo); //Formats a string
SendClientMessage(playerid, 0x00FF00AA, str); //Sends the string
GivePlayerMoney(playerid, -BusinessInfo); //Takes the $$ of for the business
return 1;
}
if(!strcmp(cmdtext, "/sell", true))
{
if(IsPlayerCloseEnoughToBis(playerid) == -1) return SendClientMessage(playerid, 0xAA3333AA, "Niste dovoljno blizu biznisa!!!"); //Checks if the player is close enough to any business
new buss = IsPlayerCloseEnoughToBis(playerid); //Shortens the function
if(BusinessInfo != playerid) return SendClientMessage(playerid, 0xAA3333AA, "Niste vlasnik ovoga biznisa!"); //Checks if the player actually owns this business
BusinessInfo = -1; //Deletes the owner.
SetPVarInt(playerid, "Businessearnings", GetPVarInt(playerid, "Businessearnings") - BusinessInfo); //Sets the players business earning down.
new str;//Creates string
format(str, sizeof(str), "Prodali ste biznis %s za $%d", BusinessInfo, BusinessInfo); //Formats a string
SendClientMessage(playerid, 0x00FF00AA, str); //Sends the string.
GivePlayerMoney(playerid, BusinessInfo); //Gives the player the $$ for selling the business =].
return 1;
}
return 0;
}
public OnPlayerPickUpPickup(playerid,pickupid) //If you have one of these add the stuff in this to your one =]
{
for(new C; C {
if(pickupid == BusinessPickup) //Checks if the pickup is for a business
{
new str;//Creates a string.
if(BusinessInfo == -1) format(str, sizeof(str), "%s ~n~~r~Cost price: $%d ~b~Sale price: $%d ~n~ ~g~Earn ammount: $%d", BusinessInfo, BusinessInfo, BusinessInfo, BusinessInfo); //Makes the string for a business with no owner.
if(BusinessInfo != -1)
{
new Pname; //Creates player name variable
GetPlayerName(BusinessInfo, Pname, 24); //Gets player name
format(str, sizeof(str), "%s ~n~~r~Cost price: $%d ~b~Sale price: $%d ~n~ ~g~Earn ammount: $%d~n~~w~Owner: %s(%d)", BusinessInfo, BusinessInfo, BusinessInfo, BusinessInfo, Pname, BusinessInfo);
GameTextForPlayer(playerid, str, 3000, 3);
}
}
}
return 1;
}
public OnPlayerDisconnect(playerid) //Copy the stuff below into your one if you have one =D.
{
for(new C; C {
if(BusinessInfo == playerid) BusinessInfo = -1; //Deletes the owner.
}
return 1;
}
stock ChangeBusinessName(BusinessID, BusNamme)
{
format(BusinessInfo, 60, "%s", BusNamme);
return 1;
}
stock DisableBusiness(BusinessID)
{
BusinessInfo = 1;
return 1;
}
stock EnableBusiness(BusinessID)
{
BusinessInfo = 0;
return 1;
}
stock DeleteBusinessOwner(BusinessID)
{
BusinessInfo = -1;
return 1;
}
stock ChangeBusinessCost(BusinessID, BussCost)
{
BusinessInfo = BussCost;
return 1;
}
stock ChangeBusinessSell(BusinessID, BussSell)
{
BusinessInfo = BussSell;
return 1;
}
stock ChangeBusinessEarn(BusinessID, Earrn)
{
BusinessInfo = Earrn;
} 