debug help
#1

how do I solve this¡?

Код:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3x-R2, ©2005-2013 SA-MP Team

[14:46:43] 
[14:46:43] Server Plugins
[14:46:43] --------------
[14:46:43]  Loading plugin: crashdetect.so
[14:46:43]   CrashDetect v4.15.1 is OK.
[14:46:43]   Loaded.
[14:46:43]  Loading plugin: streamer.so
[14:46:43] 

*** Streamer Plugin v2.7.9 by Incognito loaded ***

[14:46:43]   Loaded.
[14:46:43]  Loading plugin: sscanf.so
[14:46:43] 

[14:46:43]  ===============================

[14:46:43]       sscanf plugin loaded.     

[14:46:43]          Version:  2.8.2        

[14:46:43]    © 2012 Alex "******" Cole  

[14:46:43]  ===============================

[14:46:43]   Loaded.
[14:46:43]  Loading plugin: whirlpool.so
[14:46:43]  
[14:46:43]  ==================
[14:46:43]  
[14:46:43]   Whirlpool loaded
[14:46:43]  
[14:46:43]  ==================
[14:46:43]  
[14:46:43]   Loaded.
[14:46:43]  Loading plugin: mysql_static.so
[14:46:43]  >> plugin.mysql: R39-4 successfully loaded.
[14:46:43]   Loaded.
[14:46:43]  Loading plugin: GeoIP_Plugin.so
[14:46:43] GeoIP_Plugin got loaded.
[14:46:43]   Loaded.
[14:46:43]  Loading plugin: nativechecker.so
[14:46:43]   Loaded.
[14:46:43]  Loaded 7 plugins.

[14:46:43] 
[14:46:43] Filterscripts
[14:46:43] ---------------
[14:46:43]   Loading filterscript 'DAVIDXD.amx'...
[14:46:43]   Loading filterscript 'MAPS.amx'...
[14:46:43]   Loaded 2 filterscripts.

[14:46:43]   Successfully connected on DB 
[14:46:43]   Loading Cars & Houses 
[14:46:43]   Gate System Successfully Loaded
[14:46:43]   Role Play Successfully Loaded
[14:46:43] 
 -configuration Settings Loaded
[14:46:43] 
 -clans Loaded
[14:46:44]   12 Gates successfully loaded and created!
[14:46:44]  
[14:46:44] >----------------------------------<
[14:46:44] | fextdm load
[14:46:44] >----------------------------------<

[14:46:44] Number of vehicle models: 0
[14:46:44]   185 Bussiness Has Been Successfully loaded
[14:46:44]   No Inactive Account were found!
[14:46:44]   1957 Vehicle has been Successfully Loaded and Created
[14:46:44]   1884 House has been Successfully Loaded and Created
[14:46:44]   House, Vehicle And Business Systems Successfully Loaded
[14:46:48] -
[14:46:48] --------------House Created--------------
[14:46:48] - Houseid: 1884
[14:46:48] - Buy Cost: 300000
[14:46:48] - Sell Cost: 290000
[14:46:48] - Interior: 131
[14:46:48] - VirtualWorld: 0
[14:46:48] -----------------------------------------
[14:46:48] -
[14:46:48] -
[14:46:48] --------------House Created--------------
[14:46:48] - Houseid: 1885
[14:46:48] - Buy Cost: 300000
[14:46:48] - Sell Cost: 290000
[14:46:48] - Interior: 131
[14:46:48] - VirtualWorld: 0
[14:46:48] -----------------------------------------
[14:46:48] -
[14:47:23] Incoming connection: 41.143.159.34:61999
[14:47:23] [join] [LG]Maher has joined the server (0:41.143.159.34)
[14:47:46] Incoming connection: 179.39.85.31:19246
[14:47:47] [join] mr.nbx has joined the server (1:179.39.85.31)
[14:47:56] [chat] [[LG]Maher]: hi nbx
[14:48:59] [chat] [[LG]Maher]: hi nbx 
[14:49:02] [chat] [[LG]Maher]: hi
[14:49:14] PM: ** [LG]Maher(0): hi
[14:49:30] PM: ** [LG]Maher(0): giv me vip
[14:49:33] [part] [LG]Maher has left the server (0:1)
[14:50:03] Incoming connection: 41.143.159.34:65011
[14:50:04] [join] [LG]Maher has joined the server (0:41.143.159.34)
[14:50:26] [chat] [[LG]Maher]: mr.nbx
[14:52:23] [death] [LG]Maher died 54
[14:53:34] [chat] [[LG]Maher]: nbx ir me
[14:53:59] [chat] [[LG]Maher]: nbx ir me pliz pliz pliz pliz pliz pliz pliz pliz pliz pliz
[14:57:04] [chat] [[LG]Maher]: hi
[14:59:09] [chat] [[LG]Maher]: hola
[15:02:22] [debug] Run time error 4: "Array index out of bounds"
[15:02:22] [debug]  Accessing element at negative index -255
[15:02:22] [debug] AMX backtrace:
[15:02:22] [debug] #0 003b98dc in public cmd_buybiz (0, 7210804) from SATDMv12.amx
[15:02:22] [debug] #1 native CallLocalFunction () from sampsvr-port_2185
[15:02:22] [debug] #2 000068b4 in public OnPlayerCommandText (0, 7210772) from SATDMv12.amx
[15:02:26] [debug] Run time error 4: "Array index out of bounds"
[15:02:26] [debug]  Accessing element at negative index -255
[15:02:26] [debug] AMX backtrace:
[15:02:26] [debug] #0 003b98dc in public cmd_buybiz (0, 7210804) from SATDMv12.amx
[15:02:26] [debug] #1 native CallLocalFunction () from sampsvr-port_2185
[15:02:26] [debug] #2 000068b4 in public OnPlayerCommandText (0, 7210772) from SATDMv12.amx
[15:04:43] Incoming connection: 148.0.235.132:64570
[15:04:44] [join] Mr.Backarron has joined the server (2:148.0.235.132)
[15:05:13] [chat] [Mr.Backarron]: hi all
[15:05:33] [debug] Run time error 4: "Array index out of bounds"
[15:05:33] [debug]  Accessing element at negative index -255
[15:05:33] [debug] AMX backtrace:
[15:05:33] [debug] #0 003b98dc in public cmd_buybiz (0, 7210804) from SATDMv12.amx
[15:05:33] [debug] #1 native CallLocalFunction () from sampsvr-port_2185
[15:05:33] [debug] #2 000068b4 in public OnPlayerCommandText (0, 7210772) from SATDMv12.amx
[15:07:55] [chat] [[LG]Maher]: TRADE
Reply
#2

From what i can see, the problem appears in your gamemode and has something to do with commands.
Reply
#3

Or more precisely, the buybizz command. As clearly stated, you're trying to access an index that is out of bounds.
If you can't figute it out, please provide us that part of code.
Reply
#4

Quote:
Originally Posted by kovac
Посмотреть сообщение
Or more precisely, the buybizz command. As clearly stated, you're trying to access an index that is out of bounds.
If you can't figute it out, please provide us that part of code.
Код:
CMD:buybiz(playerid,params[]) {
   if(PlayerInfo[playerid][LoggedIn] == 1) {
     new i = GetBizID(playerid);
     if(strcmp(BizInfo[i][bOwner],pName(playerid),false) == 0) return SendClientMessage(playerid,0xDC143CAA,"ERROR: You Already own this business");
     if(PlayerInfo[playerid][bOwned] == 0) {
       if(i == -255) return SendClientMessage(playerid,-1,"ERROR: You need to be on biz icon to bought it");
       if(BizInfo[i][bOwned] == 0) {
	     new cash = GetPlayerMoney(playerid);
	     if(cash - BizInfo[i][Price] >= 0) {
		   new Query[250];
		   PlayerInfo[playerid][bInterior] = GetPlayerInterior(playerid);
		   format(Query, sizeof(Query),"UPDATE `bussines` SET `Owned` = '%d', `Owner` = '%s' WHERE `bID` = '%d'",1,pName(playerid),BizInfo[i][bID]);
           mysql_tquery(mysql, Query, "", "");
           format(Query, sizeof(Query),"UPDATE `accounts` SET `bOwned` = '%d', `bID` = '%d', `bInterior` = '%d' WHERE `Name` = '%s'",1,BizInfo[i][bID],GetPlayerInterior(playerid),pName(playerid));
           mysql_tquery(mysql, Query, "", "");
           BizInfo[i][bOwned] = 1;
		   PlayerInfo[playerid][bID] = BizInfo[i][bID];
		   PlayerInfo[playerid][bOwned] = 1;
		   strmid(BizInfo[i][bOwner], pName(playerid), 0, strlen(pName(playerid)), 255);
           DestroyDynamicMapIcon(BizInfo[i][ico]);
           BizInfo[i][ico] = CreateDynamicMapIcon(BizInfo[i][BX],BizInfo[i][BY],BizInfo[i][BZ],43,250);
           UpdateDynamic3DTextLabelText(bizTextInfo[i],0xFF0000FF,pName(playerid));
		   GivePlayerMoneyEx(playerid,-BizInfo[i][Price]);
		   new bmsg[128];
		   format(bmsg, sizeof(bmsg), "You just bought this Business (%s) for $%d. Your Business will earn you $%d/hr", BizInfo[i][Name], BizInfo[i][Price],BizInfo[i][Profit]);
		   return SendClientMessage(playerid, COLOR_GREEN, bmsg);
	     } else return SendClientMessage(playerid, 0xDC143CAA,"ERROR: You don't have enough cash to buy this biz");
	   } else return SendClientMessage(playerid, 0xDC143CAA,"ERROR: This Biz is not for sale to bought it!");
     } else return SendClientMessage(playerid, 0xDC143CAA,"ERROR: You Can only own one biz at once");
   } else return SendClientMessage(playerid, 0xDC143CAA,"ERROR: You need to  register and Login to own business");
}
Reply
#5

The mistake is in this line:
pawn Код:
if (strcmp(BizInfo[i][bOwner], pName(playerid), false) == 0) return SendClientMessage(playerid, 0xDC143CAA, "ERROR: You Already own this business");
If player is not on biz icon to buy it, "i" will be -255 and there is no checking before the line I mentioned. So you need to move this line:
pawn Код:
if(i == -255) return SendClientMessage(playerid,-1,"ERROR: You need to be on biz icon to bought it");
on top and be like this:
pawn Код:
new i = GetBizID(playerid);
if(i == -255) return SendClientMessage(playerid,-1,"ERROR: You need to be on biz icon to bought it");
if (strcmp(BizInfo[i][bOwner], pName(playerid), false) == 0) return SendClientMessage(playerid, 0xDC143CAA, "ERROR: You Already own this business");
Reply
#6

wtf is that PlayerInfo[playerid][LoggedIn] ?
so much useless code
if(PlayerInfo[playerid][bOwned] == 0) {
and what is this doing even?
GetPlayerMoney
you dont use samp default function for buying business omg what aare you donig?
PHP код:
PlayerBizCnt(p){
    new 
cnt;
    foreach(
fBizes,i){
        if(
BizInfo[i][Owner]==PlayerInfo[p][pSQLid])cnt++;
    }
    return 
cnt;
}
CMD:buybiz(pid,params[]) {
    if(
PlayerBizCnt(pid)>=1)return scm(pid,-1,"You already own business!");
    new 
GetBizID(pid);
    if(
i==-|| BizInfo[i][Owner]!=0)return scm(pid,-1,"You can't buy this business!");
    if(
PlayerInfo[pid][pCash] < BizInfo[i][Price])return scm(pid,-1,"You don't have enough money!");
    
BizInfo[i][bOwner]=PlayerInfo[pid][pSQLid];
    
PlayerInfo[pid][pCash]-=BizInfo[i][Price];
    
//saving sql
    
new s[120];
    
format(s,120,"update bussines set owner='%d' where bID='%d'",BizInfo[i][Owner],BizInfo[i][bID]);
    
mysql_tquery(mysql,s);
    
//message for player
    
format(s,120,"You just bought this Business (%s) for $%d. Your Business will earn you $%d/hr"BizInfo[i][Name], BizInfo[i][Price],BizInfo[i][Profit]);
    
scm(pid,-1,s);
    return 
1;

Reply
#7

Quote:
Originally Posted by CodeStyle175
Посмотреть сообщение
wtf is that PlayerInfo[playerid][LoggedIn] ?
so much useless code
if(PlayerInfo[playerid][bOwned] == 0) {
and what is this doing even?
GetPlayerMoney
you dont use samp default function for buying business omg what aare you donig?
PHP код:
PlayerBizCnt(p){
    new 
cnt;
    foreach(
fBizes,i){
        if(
BizInfo[i][Owner]==PlayerInfo[p][pSQLid])cnt++;
    }
    return 
cnt;
}
CMD:buybiz(pid,params[]) {
    if(
PlayerBizCnt(pid)>=1)return scm(pid,-1,"You already own business!");
    new 
GetBizID(pid);
    if(
i==-|| BizInfo[i][Owner]!=0)return scm(pid,-1,"You can't buy this business!");
    if(
PlayerInfo[pid][pCash] < BizInfo[i][Price])return scm(pid,-1,"You don't have enough money!");
    
BizInfo[i][bOwner]=PlayerInfo[pid][pSQLid];
    
PlayerInfo[pid][pCash]-=BizInfo[i][Price];
    
//saving sql
    
new s[120];
    
format(s,120,"update bussines set owner='%d' where bID='%d'",BizInfo[i][Owner],BizInfo[i][bID]);
    
mysql_tquery(mysql,s);
    
//message for player
    
format(s,120,"You just bought this Business (%s) for $%d. Your Business will earn you $%d/hr"BizInfo[i][Name], BizInfo[i][Price],BizInfo[i][Profit]);
    
scm(pid,-1,s);
    return 
1;

Perhaps if u would have read his code better u might have seen Its not so useless. He has some things there he need for certain things, and Yeah you are Just being a little shit again. Forgive me if Im wrong But Your absolutely not Here to help people and if u were, your not doing quite a good job. There is no reason for you to be such a prick on this forums so if u have some issues with Yourself Dont intoxicate this forums with it
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)