Detaljan opis problema: Ocu da stavim jos enterijera za biz a neznam gdje pa mozete li mi reci
Dio skripte:
//==============================================================================
//==============================================================================
//====== ======= ============= ================
//========== ============ ====================== =========================
//========== ============ ====================== =========================
//========== ============ ================= ====================
//========== ============ ====================== =========================
//========== ============ ====================== =========================
//========== ============ ============= =============
//==============================================================================
//==============================================================================
//==============================================================================
//==============================================================================
//******************************************************************************
// *ScotTees Dynamic Business System*
//******************************************************************************
//Originala FS stvorena od ruke Tee, editovana SnG.Scot_MisCuDi i Antonio
// |---------Credits:------------|
// | Zeex - Zcmd |
// | Darco - Dini |
// | Y_Less - Sscanf2 |
// | Tee - The FS |
// | SnG.Scot_MisCuDi - Edit FS |
// | Antonio - Edit FS |
// | Incognito- Streamer plugin.|
// |-----------------------------|
#include
#include
#include
/*
* Dini 1.6
* (c) Copyright 2006-2008 by DracoBlue
*
* @author : DracoBlue (http://dracoblue.com)
* @date : 13th May 2006
* @update : 16th Sep 2008
*
* This file is provided as is (no warranties).
*
* It's released under the terms of MIT.
*
* Feel free to use it, a little message in
* about box is honouring thing, isn't it?
*
*/
#if defined _dini_included
#endinput
#endif
#define _dini_included
#pragma library dini
#if defined MAX_STRING
#define DINI_MAX_STRING MAX_STRING
#else
#define DINI_MAX_STRING 255
#endif
stock dini_Exists(filename[]) {
return fexist(filename);
}
stock dini_Remove(filename[]) {
return fremove(filename);
}
stock dini_Create(filename[]) {
if (fexist(filename)) return false;
new File:fhnd;
fhnd=fopen(filename,io_write);
if (fhnd) {
fclose(fhnd);
return true;
}
return false;
}
stock dini_Set(filename[],key[],value[]) {
// If we have no key, it can't be set
// we also have no chance to set the value, if all together is bigger then the max string
new key_length = strlen(key);
new value_length = strlen(value);
if (key_length==0 || key_length+value_length+2>DINI_MAX_STRING) return false;
new File:fohnd, File:fwhnd;
new tmpres;
new bool:wasset=false;
// Let's remove the old *.part file if there was one.
format(tmpres,sizeof(tmpres),"%s.part",filename);
fremove(tmpres);
// We'll open the source file.
fohnd=fopen(filename,io_read);
if (!fohnd) return false;
fwhnd=fopen(tmpres,io_write);
if (!fwhnd) {
// we can't open the second file for writing, so .. let's close the open one and exit.
fclose(fohnd);
return false;
}
while (fread(fohnd,tmpres)) {
if (
!wasset
&& tmpres=='='
&& !strcmp(tmpres, key, true, key_length)
) {
// We've got what needs to be replaced!
format(tmpres,sizeof(tmpres),"%s=%s",key,value);
wasset=true;
} else {
DINI_StripNewLine(tmpres);
}
fwrite(fwhnd,tmpres);
fwrite(fwhnd,"\r\n");
}
if (!wasset) {
format(tmpres,sizeof(tmpres),"%s=%s",key,value);
fwrite(fwhnd,tmpres);
fwrite(fwhnd,"\r\n");
}
fclose(fohnd);
fclose(fwhnd);
format(tmpres,sizeof(tmpres),"%s.part",filename);
if (DINI_fcopytextfile(tmpres,filename)) {
return fremove(tmpres);
}
return false;
}
stock dini_IntSet(filename[],key[],value) {
new valuestring;
format(valuestring,DINI_MAX_STRING,"%d",value);
return dini_Set(filename,key,valuestring);
}
stock dini_Int(filename[],key[]) {
return strval(dini_Get(filename,key));
}
stock dini_FloatSet(filename[],key[],Float:value) {
new valuestring;
format(valuestring,DINI_MAX_STRING,"%f",value);
return dini_Set(filename,key,valuestring);
}
stock Float:dini_Float(filename[],key[]) {
return floatstr(dini_Get(filename,key));
}
stock dini_Bool(filename[],key[]) {
return strval(dini_Get(filename,key));
}
stock dini_BoolSet(filename[],key[],value) {
if (value) {
return dini_Set(filename,key,"1");
}
return dini_Set(filename,key,"0");
}
stock dini_Unset(filename[],key[]) {
// If we have no key, it can't be set
// we also have no chance to unset the key, if all together is bigger then the max string
new key_length = strlen(key);
if (key_length==0 || key_length+2>DINI_MAX_STRING) return false;
new File:fohnd, File:fwhnd;
new tmpres;
// Let's remove the old *.part file if there was one.
format(tmpres,DINI_MAX_STRING,"%s.part",filename);
fremove(tmpres);
// We'll open the source file.
fohnd=fopen(filename,io_read);
if (!fohnd) return false;
fwhnd=fopen(tmpres,io_write);
if (!fwhnd) {
// we can't open the second file for writing, so .. let's close the open one and exit.
fclose(fohnd);
return false;
}
while (fread(fohnd,tmpres)) {
if (
tmpres=='='
&& !strcmp(tmpres, key, true, key_length)
) {
// We've got what needs to be removed!
} else {
DINI_StripNewLine(tmpres);
fwrite(fwhnd,tmpres);
fwrite(fwhnd,"\r\n");
}
}
fclose(fohnd);
fclose(fwhnd);
format(tmpres,DINI_MAX_STRING,"%s.part",filename);
if (DINI_fcopytextfile(tmpres,filename)) {
return fremove(tmpres);
}
return false;
}
stock dini_Get(filename[],key[]) {
new tmpres;
new key_length = strlen(key);
if (key_length==0 || key_length+2>DINI_MAX_STRING) return tmpres;
new File:fohnd;
fohnd=fopen(filename,io_read);
if (!fohnd) return tmpres;
while (fread(fohnd,tmpres)) {
if (
tmpres=='='
&& !strcmp(tmpres, key, true, key_length)
) {
/* We've got what we need */
DINI_StripNewLine(tmpres);
strmid(tmpres, tmpres, key_length + 1, strlen(tmpres), DINI_MAX_STRING);
fclose(fohnd);
return tmpres;
}
}
fclose(fohnd);
return tmpres;
}
stock dini_Isset(filename[],key[]) {
new key_length = strlen(key);
if (key_length==0 || key_length+2>DINI_MAX_STRING) return false;
new File:fohnd;
fohnd=fopen(filename,io_read);
if (!fohnd) return false;
new tmpres;
while (fread(fohnd,tmpres)) {
if (
tmpres=='='
&& !strcmp(tmpres, key, true, key_length)
) {
// We've got what we need
fclose(fohnd);
return true;
}
}
fclose(fohnd);
return false;
}
stock DINI_StripNewLine(string[]) {
new len = strlen(string);
if (string==0) return ;
if ((string[len - 1] == '\n') || (string[len - 1] == '\r')) {
string[len - 1] = 0;
if (string==0) return ;
if ((string[len - 2] == '\n') || (string[len - 2] == '\r')) string[len - 2] = 0;
}
}
stock DINI_fcopytextfile(oldname[],newname[]) {
new File:ohnd,File:nhnd;
if (!fexist(oldname)) return false;
ohnd=fopen(oldname,io_read);
if (!ohnd) return false;
nhnd=fopen(newname,io_write);
if (!nhnd) {
fclose(ohnd);
return false;
}
new tmpres;
while (fread(ohnd,tmpres)) {
DINI_StripNewLine(tmpres);
format(tmpres,sizeof(tmpres),"%s\r\n",tmpres);
fwrite(nhnd,tmpres);
}
fclose(ohnd);
fclose(nhnd);
return true;
}
#include
#define MAX_BUSS 100
#define NO_OWNER "INVALID_PLAYER_ID"
#define CASE_SENSETIVE true
#define White 0xFFFFFFFF
#define Yellow 0xFFFF00FF
#define Grey 0xC0C0C0FF
#define Red 0xFF0000AA
#define Green 0x45E01FFF
new cpid;
new String;
new file;
new Name;
new Float:X,Float:Y,Float:Z;
new Label;
new BizExit;
enum Business
{
CP,
Text3D:bLabel,
Cost,
bName,
}
new BusinessInfo;
forward Payday(playerid);
stock Float:GetPosInFrontOfPlayer(playerid, &Float:x, &Float:y, Float:distance)
{
new Float:a;
GetPlayerPos(playerid, x, y, a);
switch(IsPlayerInAnyVehicle(playerid))
{
case 0: GetPlayerFacingAngle(playerid, a);
case 1: GetVehicleZAngle(GetPlayerVehicleID(playerid), a);
}
x += (distance * floatsin(-a, degrees));
y += (distance * floatcos(-a, degrees));
return a;
}
public OnFilterScriptInit()
{
print("___________________________");
print("--Dynamic Business Loaded--");
print(" --Made by: Tee-- ");
print("___________________________");
LoadBusinesses();
SetTimer("Payday",1_800_000,true);
BizExit = CreateDynamicCP(-25.9351,-141.5631,1003.5469,1,-1,16,-1,20);
return 1;
}
public OnFilterScriptExit()
{
UnloadBusinesses();
return 1;
}
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
for(new i = 0;i {
if(checkpointid == BusinessInfo)
{
cpid = i;
format(file,sizeof(file),"Business/%i.ini",i);
if(dini_Int(file, "Ima Vlasnika") == 0)
{
ShowPlayerDialog(playerid,219,DIALOG_STYLE_MSGBOX,"Kupi Firmu","Zelis li kupiti ovu firmu?","Kupi","Odustani");
}
else
{
SetPlayerPos(playerid, -25.132598,-139.066986,1003.546875);
SetPlayerInterior(playerid, 16);
SetPlayerVirtualWorld(playerid, i);
SetPlayerFacingAngle(playerid, 359.9003);
}
}
}
if(checkpointid == BizExit)
{
format(file, sizeof(file), "Business/%i.ini", GetPlayerVirtualWorld(playerid));
SetPlayerPos(playerid, dini_Float(file, "SpawnOutX"), dini_Float(file, "SpawnOutY"), dini_Float(file, "BusZ"));
SetPlayerFacingAngle(playerid, dini_Float(file, "A"));
SetPlayerVirtualWorld(playerid, 0);
SetPlayerInterior(playerid, 0);
}
return 1;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
if(dialogid == 219)
{
if(response == 1)
{
if(GetPlayerBusinessID(playerid) == 1)return 0;
new busid;
format(file,sizeof(file),"Business/%i.ini",cpid);
if(GetPlayerBusinessID(playerid) > -1)return SendClientMessage(playerid,Red,"Vec posjedujes firmu");
if(dini_Int(file,"Cost") > GetPlayerMoney(playerid))return SendClientMessage(playerid,Red,"Nemas dovoljno novaca, da bi si prisutio ovu firmu.");
GivePlayerMoney(playerid, -dini_Int(file,"Cost"));
GetPlayerName(playerid,Name,sizeof(Name));
dini_Set(file, "Name", Name);
dini_Set(file, "Owner",Name);
dini_IntSet(file, "OwnedBus",1);
dini_IntSet(file, "HasOwner",1);
format(Label, sizeof(Label), "{ccccff}%s firma\n\n{999999}%s\n{00BC00}Cjena: {999999}$%i\n{00BC00}ID: {999999}%i",Name,dini_Get(file, "Owner"),dini_Int(file, "Cost"),busid);
Update3DTextLabelText(BusinessInfo[cpid],White,Label);
format(String,sizeof(String),"Uspijesno ste kupili firmu: %s.",dini_Get(file, "Name"));
SendClientMessage(playerid,Green,String);
}
if(response == 0)
{
SendClientMessage(playerid,Yellow,"Odabrao si da ne kupis ovaj biznis.");
}
}
if(dialogid == 220)
{
if(response == 1)
{
GetPlayerName(playerid,Name,sizeof(Name));
format(file,sizeof(file),"Business/%i.ini",GetPlayerBusinessID(playerid));
format(Label, sizeof(Label), "{ccccff}Na prodaju!\n\n{999999}Nema vlasnika\n{00BC00}: {999999}$%i",dini_Get(file, "Name"),dini_Int(file, "Cost"));
Update3DTextLabelText(BusinessInfo[cpid],White,Label);
dini_Set(file, "Owner","No Owner");
dini_IntSet(file, "Cost",dini_Int(file, "Cost"));
dini_IntSet(file, "OwnedBus",0);
dini_IntSet(file, "HasOwner",0);
GivePlayerMoney(playerid,dini_Int(file, "Cost")/2);
SendClientMessage(playerid,Green,"Uspijesno ste prodali biznis, te dobili 50 posto od ukupne cjene.");
}
}
return 1;
}
// Ova komanda sluzi za pravljenje Business
COMMAND:stvorifirmu(playerid, params[])
{
new busid,cost,name;
new Float:x,Float:y;
if(!IsPlayerAdmin(playerid))return 0;
if(sscanf(params,"I(500000)S(Na prodaju)",cost,name))return SendClientMessage(playerid, 0xFF0000AA, "Koristi: /stvorifirmu [ime frime]");
for(new i=0; i {
format(file,sizeof(file),"Business/%i.ini",i);
if(!dini_Exists(file))
{
busid = i;
break;
}
}
format(file,sizeof(file),"Frime/%i.ini",busid);
BusinessInfo = name;
BusinessInfo = cost;
GetPlayerPos(playerid, X, Y, Z);
GetPosInFrontOfPlayer(playerid, x, y, -2.5);
dini_Create(file);
dini_Set(file, "Name", name);
dini_Set(file, "Owner","No Owner");
dini_IntSet(file, "Cost",cost);
dini_FloatSet(file, "BusX", X);
dini_FloatSet(file, "BusY", Y);
dini_FloatSet(file, "BusZ", Z);
dini_FloatSet(file, "SpawnOutX", x);
dini_FloatSet(file, "SpawnOutY", y);
dini_FloatSet(file, "SpawnOutZ", Z);
dini_IntSet(file, "World",GetPlayerVirtualWorld(playerid));
dini_IntSet(file, "Interior",GetPlayerInterior(playerid));
dini_IntSet(file, "OwnedBus",0);
dini_IntSet(file, "HasOwner",0);
BusinessInfo = CreateDynamicCP(X,Y,Z,1.0,GetPlayerVirtualWorld(playerid),GetPlayerInterior(playerid),-1,50.0);
format(Label, sizeof(Label), "{ccccff}%s\n{999999}Nema vlasnika\n{00BC00}Cjena: {999999}$%i\nID: %i", name,cost,busid);
BusinessInfo = Create3DTextLabel(Label,White,X,Y,Z,100.0,GetPlayerVirtualWorld(playerid),1);
format(String,sizeof(String),"Firma stvorena. Ime: %s | Cjena: $%i | Vlasnik: Nema vlasnika | ID: %i",name,cost,busid);
SendClientMessage(playerid,Green,String);
return 1;
}
COMMAND:imefirme(playerid, params[])
{
new name;
if(sscanf(params,"s",name))return SendClientMessage(playerid, 0xFF0000AA, "Koristi: /imefirme ");
if(GetPlayerBusinessID(playerid) == -1) return SendClientMessage(playerid,Red,"Ne posjedujes firmu.");
format(file,sizeof(file),"Business/%i.ini",GetPlayerBusinessID(playerid));
dini_Set(file, "Name", name);
format(String,sizeof(String),"Ime firme promjenjeno u: %s",name);
SendClientMessage(playerid,Green,String);
format(Label, sizeof(Label), "{ccccff}%s\n\n{999999}%s\n{00BC00}Cost: {999999}$%i\n{00BC00}ID: {999999}%i",name, dini_Get(file, "Owner"),dini_Int(file, "Cost"),GetPlayerBusinessID(playerid));
Update3DTextLabelText(BusinessInfo[GetPlayerBusinessID(playerid)],White,Label);
return 1;
}
//Ova komanda koristi se za brisanje firme
COMMAND:brisifirmu(playerid, params[])
{
new busid;
if(!IsPlayerAdmin(playerid)) return 0;
if(sscanf(params, "i", busid)) return SendClientMessage(playerid,0xC0C0C0FF,"Koristi: /brisifirmu [ID firme]");
format(file,sizeof(file),"Business/%i.ini",busid);
if(!dini_Exists(file))return SendClientMessage(playerid,Red,"Ta firma ne postoji.");
format(String,sizeof(String),"Uspijesno ste maknuli firmu ID-a: %i.",busid);
SendClientMessage(playerid,Yellow,String);
DestroyDynamicCP(BusinessInfo);
Delete3DTextLabel(BusinessInfo);
dini_Remove(file);
return 1;
}
//Ova komanda omogucuje da owner proda svoju firmu
COMMAND:prodajfirmu(playerid, params[])
{
if(GetPlayerBusinessID(playerid) == -1)return SendClientMessage(playerid,Red,"Ne posjedujes biznis.");
ShowPlayerDialog(playerid,220,DIALOG_STYLE_MSGBOX,"Prodaja firme","Zelis li prodati firmu?","Prodaj","Odustani");
return 1;
}
//This function gets the owner of a specific business.
stock GetBusOwner(bussid)
{
new owner;
format(owner, MAX_PLAYER_NAME, NO_OWNER);
format(String, sizeof(String), "Business/%i.ini", bussid);
if(dini_Exists(String))
{
format(owner, MAX_PLAYER_NAME, "%s", dini_Get(String, "Owner"));
return owner;
}
return owner;
}
//This function gets a business ID (it also tells if a player owns a business or not).
stock GetPlayerBusinessID(playerid)
{
new returnval, found=0;
for(new i = 0;i {
format(String,sizeof(String),"Business/%i.ini",i);
if(dini_Exists(String))
{
GetPlayerName(playerid,Name,sizeof(Name));
if(!strcmp(Name, dini_Get(String,"Owner"), false))
{
returnval = i;
found = 1;
}
}
}
if(!found) returnval = -1;
return returnval;
}
//Ova komanda omogucuje da se skloni owner biza
COMMAND:defirma(playerid, params[])
{
new id;
if(!IsPlayerAdmin(playerid))return 0;
if(sscanf(params,"u", id))return SendClientMessage(playerid, 0xFF0000AA, "Koristi: /defirma ");
if(GetPlayerBusinessID(id) == -1)return SendClientMessage(playerid,Red,"Taj igraci ne posjeduje biz.");
format(String,sizeof(String),"Business/%i.ini",GetPlayerBusinessID(id));
format(Label, sizeof(Label), "{ccccff}%s\n{999999}Nema vlasnika\n{00BC00}Cjena: {999999}$%i",dini_Get(String, "Name"),dini_Int(String, "Cost"));
Update3DTextLabelText(BusinessInfo[GetPlayerBusinessID(id)],White,Label);
dini_Set(String, "Owner","No Owner");
dini_IntSet(String, "Cost",dini_Int(String, "Cost"));
dini_IntSet(String, "OwnedBus",0);
dini_IntSet(String, "HasOwner",0);
GivePlayerMoney(id,dini_Int(String, "Cost")/4);
format(String, sizeof(String), "Igrac %s vise nije vlasnik firme.",Name);
SendClientMessage(playerid,Red, String);
return 1;
}
//This function loads every business.
stock LoadBusinesses()
{
new count = 0;
for(new i=0; i {
format(String,sizeof(String),"Business/%i.ini",i); // the ID would be the name of the file, 1 2 3 4 5 etc
if(dini_Exists(String)) //thats the easiest way to get IDs of them, you don't need to write it inside of the file itself if the name of the file is a number.. looks good?
{
BusinessInfo = CreateDynamicCP(dini_Float(String, "BusX"),dini_Float(String, "BusY"),dini_Float(String, "BusZ"),1.0,dini_Int(String, "World"),dini_Int(String, "Interior"),-1,100.0);
if(!strcmp(GetBusOwner(i), NO_OWNER, CASE_SENSETIVE))
{
format(Label, sizeof(Label), "{ccccff}%s\n{999999}No Owner\n{00BC00}Cost: {999999}$%i",dini_Get(String, "Name"),dini_Int(String, "Cost"));
BusinessInfo = Create3DTextLabel(Label,White,dini_Float(String, "BusX"),dini_Float(String, "BusY"),dini_Float(String, "BusZ")+1,100.0,0,1);
}
if(strcmp(GetBusOwner(i), NO_OWNER, CASE_SENSETIVE))//i will be what index it's at in the loop which would be the ID as its looping through all the files
{
format(Label, sizeof(Label), "{ccccff}%s\n\n{999999}%s\n{00BC00}Cost: {999999}$%i\n{00BC00}ID: {999999}%i",dini_Get(String, "Name"), dini_Get(String, "Owner"),dini_Int(String, "Cost"),i);
BusinessInfo = Create3DTextLabel(Label,White,dini_Float(String, "BusX"),dini_Float(String, "BusY"),dini_Float(String, "BusZ")+1,100.0,0,1);
}
count++;
}
}
return printf("Total Businesses Loaded: %i",count);
}
//This function gets the last bused business ID.
stock GetLastBusinessID()
{
new count = 0;
for(new i=0; i {
format(String,sizeof(String),"Business/%i.ini",i);
{
count++;
}
}
return count;
}
//This function unloads every business.
stock UnloadBusinesses()
{
for(new i=0; i {
Delete3DTextLabel(BusinessInfo);
DestroyDynamicCP(BusinessInfo);
}
return 1;
}
//This is used by RCON admins. Either to debug or to force a payday.
COMMAND:ubrzajpay(playerid,params[])
{
if(!IsPlayerAdmin(playerid))return 0;
SendClientMessage(playerid,Grey,"Ubrzali ste payday.");
for(new i=0; i < MAX_PLAYERS; i++) if(IsPlayerConnected(i)) Payday(i);
return 1;
}
#define TIMEDEBUG 1 //set this to 0 if you don't want it to print the time it took for this function to execute
//This function is the payday (to pay the owners).
public Payday(playerid)
{
#if TIMEDEBUG == 1
new tick = GetTickCount();
#endif
if(GetPlayerBusinessID(playerid) != -1)
{
new RandMoney = rand(100_000, 250_000), msg;
GivePlayerMoney(playerid, RandMoney);
format(msg, sizeof(msg), " Primili ste $%i", RandMoney);
SendClientMessage(playerid, Green, msg);
format(msg, sizeof(msg), "~w~Primili ste ~g~$%i ~w~iz vase firme", RandMoney);
GameTextForPlayer(playerid, msg, 4000,3);
}
else return SendClientMessage(playerid, Green, "Da imate firmu, primili biste payday!");
#if TIMEDEBUG == 1
printf("Time taken to execute Payday(): %i", GetTickCount()-tick);
#endif
return 1;
}
stock pName(playerid)
{
new name;
GetPlayerName(playerid, name, sizeof(name));
return name;
}
stock rand(minnum = cellmin,maxnum = cellmax) return random(maxnum - minnum + 1) + minnum; //swtiches so much better
Neke slike/video za lakse dobivanje pomoci(neobavezno): /
