Szerző Téma: Biz system  (Megtekintve 1320 alkalommal)

Nem elérhető nyE

  • 1745
    • Profil megtekintése
Biz system
« Dátum: 2010. December 14. - 19:03:04 »
0 Show voters
Hello!
Hiv. fórumon találtam egy tutot amiben leírják, hogy lehet házvevõs scriptet készíteni. Link
Annyi bajom van vele, hogy amikor felveszem a pickupot akkor nem ír ki semmit de ha beírom azt, hogy /buy akkor megveszi.
Így néz ki:
 
#include <a_samp>
#define MAX_BUSINESSES 100 //Increase if you need more but it will make your script larger.
#define PayoutTimer 360 //Number of seconds before the player gets his next pay.
enum BusInfo
{
    Float:BusX, //Business X Pos
    Float:BusY,  //Business Y Pos
    Float:BusZ,  //Business Z Pos
    BusCost,  //Business buy cost
    BusSell,  // Business sell cost
    BusEarn,  //Business earn
    BusOwner, // ID of the player that owns the business
    BusName[60], // The name of the business
    Disabled //If the business is disabled or not
};
//Add these at the top of your script.
new BusinessPickup[MAX_BUSINESSES]; // 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[businessCount][busOwner]
new BusinessInfo[MAX_BUSINESSES][busInfo]; // All the enum info is saved into one variable.
CreateBusiness(BusinessName[], Float:XPos, Float:YPos, Float:ZPos, Price, Sell, Earn)
{
    if(!strlen(BusinessName)) 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[0][....]
    BusinessInfo[businessCount][busX] = XPos; //Sets the Xpos into the variable for long term saving.
    BusinessInfo[businessCount][busY] = YPos; //Sets the Ypos into the variable for long term saving.
    BusinessInfo[businessCount][busZ] = ZPos; //Sets the Zpos into the variable for long term saving.
    BusinessInfo[businessCount][busCost] = Price; //Sets the price into the variable for long term saving.
    BusinessInfo[businessCount][busSell] = Sell; //Sets the Sell cost into the variable for long term saving.
    BusinessInfo[businessCount][busEarn] = Earn; // //Sets the earning into the variable for long term saving.
    BusinessInfo[businessCount][busOwner] = -1; //Sets the business owner into the variable for long term saving.
    BusinessPickup[businessCount] = AddStaticPickup(1272, 19, XPos, YPos, ZPos, -1); //Adds the pickup
    format(BusinessInfo[businessCount][busName], 60, \"%s\", BusinessName); //Sets the business name into the variable for long term saving.
    return BusinessCount; //Will return the business ID
}
 
public OnFilterScriptInit() //Change to OnFilterScriptInit if it\'s a filterscript =].
{
    SetTimer(\"Payouttimer\", PayoutTimer, true); //Sets the timer =].
      CreateBusiness(\"TestBiz\", 1317.5702,1278.6991,10.8594, 13337, 10000, 100);
    return 1;
}
stock IsPlayerCloseEnoughToBis(playerid)
{
    for(new C; C<BusinessCount+1; C++)//Loops through all businesses
    {
        if(IsPlayerInRangeOfPoint(playerid, 3, BusinessInfo[C][busX],  BusinessInfo[C][busY], BusinessInfo[C][busZ])) return C; // Checks if a business is close enough
    }
    return -1;
}
forward Payouttimer(); //You must forward a timer
public Payouttimer()
{
    for(new i; i<GetMaxPlayers(); i++) // Loops through every player
    {
        if(GetPVarInt(i, \"Businessearnings\") != 0) //Does the player earn any $$
        {
            new Str[100]; // 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, \"You are not close enough to a business!!!\"); //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[buss][Disabled] == 1) return SendClientMessage(playerid, 0xAA3333AA, \"Business is disabled!!\"); //This is for a function down at the bottom of this tutorial
    if(GetPlayerMoney(playerid) < BusinessInfo[buss][busCost]) return SendClientMessage(playerid, 0xAA3333AA, \"You don\'t have enough money for this business =D\"); //Will return this if the player is a poor nub =D.
    if(BusinessInfo[buss][busOwner] != -1) return SendClientMessage(playerid, 0xAA3333AA, \"Someone already owns this business!\"); //Will return it if somebody online owns the business.
    BusinessInfo[buss][busOwner] = playerid; //Sets the business owner
    SetPVarInt(playerid, \"Businessearnings\" , GetPVarInt(playerid, \"Businessearnings\") + BusinessInfo[buss][busEarn]); // Makes the players earn more
    new str[100]; //Creates a string
    format(str, sizeof(str), \"You have brought the business %s for $%d. You will now earn $%d\",  BusinessInfo[buss][busName], BusinessInfo[buss][busCost], BusinessInfo[buss][busEarn]); //Formats a string
    SendClientMessage(playerid, 0x00FF00AA, str); //Sends the string
    GivePlayerMoney(playerid, -BusinessInfo[buss][busCost]); //Takes the $$ of for the business
    return 1;
}
if(!strcmp(cmdtext, \"/sell\", true))
{
    if(IsPlayerCloseEnoughToBis(playerid) == -1) return SendClientMessage(playerid, 0xAA3333AA, \"You are not close enough to a business!!!\"); //Checks if the player is close enough to any business
    new buss = IsPlayerCloseEnoughToBis(playerid); //Shortens the function
    if(BusinessInfo[buss][busOwner] != playerid) return SendClientMessage(playerid, 0xAA3333AA, \"You don\'t own this business!\"); //Checks if the player actually owns this business
    BusinessInfo[buss][busOwner] = -1; //Deletes the owner.
    SetPVarInt(playerid, \"Businessearnings\", GetPVarInt(playerid, \"Businessearnings\") - BusinessInfo[buss][busEarn]); //Sets the players business earning down.
    new str[100];//Creates string
    format(str, sizeof(str), \"You have sold the business %s for $%d\",  BusinessInfo[buss][busName], BusinessInfo[buss][busCost]); //Formats a string
    SendClientMessage(playerid, 0x00FF00AA, str); //Sends the string.
    GivePlayerMoney(playerid, BusinessInfo[buss][busSell]); //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<BusinessCount+1; C++)//Loops through all businesses
    {
        if(pickupid == BusinessPickup[C]) //Checks if the pickup is for a business
        {
            new str[150];//Creates a string.
            if(BusinessInfo[C][busOwner] == -1) format(str, sizeof(str), \"%s ~n~~r~Cost price: $%d ~b~Sale price: $%d ~n~ ~g~Earn ammount: $%d\", BusinessInfo[C][busName], BusinessInfo[C][busCost], BusinessInfo[C][busSell], BusinessInfo[C][busEarn]); //Makes the string for a business with no owner.
            if(BusinessInfo[C][busOwner] != -1)
            {
                new Pname[24]; //Creates player name variable
                GetPlayerName(BusinessInfo[C][busOwner], 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[C][busName], BusinessInfo[C][busCost], BusinessInfo[C][busSell], BusinessInfo[C][busEarn], Pname, BusinessInfo[C][busOwner]);
                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<BusinessCount+1; C++)//Loops through all businesses
    {
        if(BusinessInfo[C][busOwner] == playerid)  BusinessInfo[C][busOwner] = -1; //Deletes the owner.
    }
    return 1;
}
stock ChangeBusinessName(BusinessID, BusNamme)
{
    format(BusinessInfo[businessID][busName], 60, \"%s\", BusNamme);
    return 1;
}
stock DisableBusiness(BusinessID)
{
    BusinessInfo[businessID][Disabled] = 1;
    return 1;
}
stock EnableBusiness(BusinessID)
{
    BusinessInfo[businessID][Disabled] = 0;
    return 1;
}
stock DeleteBusinessOwner(BusinessID)
{
    BusinessInfo[businessID][busOwner] = -1;
    return 1;
}
stock ChangeBusinessCost(BusinessID, BussCost)
{
    BusinessInfo[businessID][busCost] = BussCost;
    return 1;
}
stock ChangeBusinessSell(BusinessID, BussSell)
{
    BusinessInfo[businessID][busSell] = BussSell;
    return 1;
}
stock ChangeBusinessEarn(BusinessID, Earrn)
{
    BusinessInfo[businessID][busEarn] = Earrn;
}

Nem elérhető Sheet

  • 1508
  • Támogató
    • Profil megtekintése
Biz system
« Válasz #1 Dátum: 2010. December 14. - 19:34:34 »
0 Show voters
Énis kipróbáltam, csak nekem + annyi a baj, hogy ha megveszem elkezdi a szöveget floodolni

Nem elérhető nyE

  • 1745
    • Profil megtekintése
Biz system
« Válasz #2 Dátum: 2010. December 14. - 20:08:40 »
0 Show voters
Az a timer miatt van.
 
#define PayoutTimer 360

 

SimplePortal 2.3.7 © 2008-2024, SimplePortal