SA-MP Forums Archive
biz help - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: biz help (/showthread.php?tid=603025)



biz help - kevi11 - 17.03.2016

Hi guys, I have a problem with this script, pretty much when I go into the game and I / createbiz the server crashes but when I do it in duty says you're not allowed to use this command so how could I do? this is the cmd:

PHP код:
CMD:createbiz(playeridparams[])
{
    new 
typestring[128];
    if(!
IsPlayerConnected(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
    if(
IsPlayerAdmin(playerid)) return SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
//    if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");
    
if(sscanf(params"i"type))
    {
        
SendClientMessage(playeridCOLOR_WHITE"USAGE: /createbiz [type]");
        
SendClientMessage(playeridCOLOR_GREY"TYPES: 1) 24/7 | 2) Clothes Shop | 3) Ammunation | 4) Club | 5) Advertisement Agency | 6) Fast Food | 7) Casino");
        return 
1;
    }
    if(
type || type 7) return SendClientMessage(playeridCOLOR_GREY"Businesses are between 1 and 7.");
    for(new 
idx=1idx<MAX_BIZidx++)
    {
        if(!
BizInfo[idx][bType])
        {
            
//g_bizRobber[idx] = -1;
            // Getting Business Setup
            
new Float:XFloat:YFloat:Z;
            
GetPlayerPos(playeridXYZ);
            
// Making Business
            
BizInfo[idx][bType] = type;
            
BizInfo[idx][bStatus] = 0;
            
format(BizInfo[idx][bOwner], 32"The State");
            
BizInfo[idx][bX] = X;
            
BizInfo[idx][bY] = Y;
            
BizInfo[idx][bZ] = Z;
            
BizInfo[idx][bMoney] = 0;
            
BizInfo[idx][bProducts] = 0;
            
BizInfo[idx][bSold] = 0;
            
BizInfo[idx][bLevel] = 1;
            
BizInfo[idx][bPrice] = 500000;
            
BizInfo[idx][bPickup] = CreateDynamicPickup(12721XYZ0);
            
format(stringsizeof(string), "[Business ID: %d]\nBusiness Type: %s\nBusiness Owner: %s\nStatus: For Sale\nPrice: $%d"idxRBT(idx), BizInfo[idx][bOwner], BizInfo[idx][bPrice]);
            
BizInfo[idx][bText] = CreateDynamic3DTextLabel(stringCOLOR_WHITEXYZ15);
            
format(stringsizeof(string), "{FF0000}[Admin Warn]{FF6347} %s has created business ID %d."RPN(playerid), idx);
            
//SendAdminMessage(COLOR_DARKRED, 1, string);
            
Log("logs/business.log"string);
            
idx MAX_BIZ;
        }
    }
    return 
1;




Re: biz help - VenusDarkX - 17.03.2016

May be..try to uncomment this line:
if(!aDuty[playerid]) return SendClientMessage(playerid, COLOR_GREY, "You are not on admin duty.");


Re: biz help - kevi11 - 17.03.2016

What?


Re: biz help - Untonyst - 17.03.2016

What is the size of the array?

PHP код:
format(BizInfo[idx][bOwner], 32"The State"); 
Maybe out of bounds array index?

Crashdetecr included? What logs?


Re: biz help - kevi11 - 17.03.2016

Help me or not??


Re: biz help - Stev - 17.03.2016

Was cannot help you, if you want help yourself. Answer Untonyst question, Then we can determine what problems your having

This:
Quote:
Originally Posted by Untonyst
Посмотреть сообщение
What is the size of the array?

PHP код:
format(BizInfo[idx][bOwner], 32"The State"); 
Maybe out of bounds array index?

Crashdetecr included? What logs?



Re: biz help - kevi11 - 17.03.2016

As you lower the admin level to use the command / created biz?


Re: biz help - introzen - 17.03.2016

Check business.log and see if it logs the string please. Also, you need to put "!" before "IsPlayerAdmin".


Re: biz help - Konstantinos - 17.03.2016

You should always have crashdetect plugin installed because it will help you with server crashes and run time errors.

It seems to me that the problem is the Log function itself and to be more specific, it tries to write to a file with invalid handle. The wiki shows how to check if the file handle is valid to avoid server crashes. The same applies for the all the file functions that require a handle parameter.

EDIT: This line doesn't make sense in the loop.
pawn Код:
idx = MAX_BIZ;