SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 04/12/2019, 08:42 AM   #11
Coox
Little Clucker
 
Coox's Avatar
 
Join Date: Feb 2018
Posts: 34
Reputation: 0
Default Re: Crash on editing objects

Code:
stock FreeClothingSlot(playerid)
{
	for(new i = 1; i < MAX_CLOTHING_ITEMS; i++)
	{
		if(!ClothingData[playerid][i][attachment_SQLID])
			return i;
	}
	return -1;
}
Code:
----------
Loaded log file: "server_log.txt".
----------

SA-MP Dedicated Server
----------------------
v0.3.DL-R1, (C)2005-2018 SA-MP Team

[22:02:25] 
[22:02:25] Server Plugins
[22:02:25] --------------
[22:02:25]  Loading plugin: crashdetect.so
[22:02:25]   CrashDetect plugin 4.19.4
[22:02:25]   Loaded.
[22:02:25]  Loading plugin: discord-connector.so
[22:02:26]  >> plugin.dc-connector: 0.2.4 successfully loaded.
[22:02:26]   Loaded.
[22:02:26]  Loading plugin: sscanf.so
[22:02:26] 

[22:02:26]  ===============================

[22:02:26]       sscanf plugin loaded.     

[22:02:26]          Version:  2.8.2        

[22:02:26]    (c) 2012 Alex "******" Cole  

[22:02:26]  ===============================

[22:02:26]   Loaded.
[22:02:26]  Loading plugin: irc.so
[22:02:26] 

*** IRC Plugin v1.4.8 by Incognito loaded ***

[22:02:26]   Loaded.
[22:02:26]  Loading plugin: mysql_static.so
[22:02:26]  >> plugin.mysql: R39-6 successfully loaded.
[22:02:26]   Loaded.
[22:02:26]  Loading plugin: streamer.so
[22:02:26] 

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

[22:02:26]   Loaded.
[22:02:26]  Loaded 6 plugins.

[22:02:26] 
[22:02:26] Filterscripts
[22:02:26] ---------------
[22:02:26]   Loading filterscript 'pdext.amx'...
[22:02:26]   Unable to load filterscript 'pdext.amx'.
[22:02:26]   Loading filterscript 'pdint.amx'...
[22:02:26]   Unable to load filterscript 'pdint.amx'.
[22:02:26]   Loading filterscript 'pda.amx'...
[22:02:26]   Unable to load filterscript 'pda.amx'.
[22:02:26]   Loading filterscript 'rental.amx'...
[22:02:26]   Loaded 1 filterscripts.

[22:02:26] -mSelection- WARNING: Failed to load list: "skins.txt"
[22:02:26] [MYSQL]: Connection to 'server_3297_lsrp' successful!
[22:02:26] Loading - Mapping for apartment interior was loaded.
[22:02:26] Loading - Mapping for Pay n Sprays were loaded.
[22:02:26] Loading - Mapping for Mod Shops were loaded.
[22:02:26] Loading - Mapping for Toll Booths were loaded.
[22:02:26] Loading - Map for Idlewood was loaded.
[22:02:26] Loading - Map for FBI (ext and int) was loaded.
[22:02:26] Loading - Map for FD exterior was loaded.
[22:02:26] Loading - Map for Complexs was loaded.
[22:02:26] Number of vehicle models: 1
[22:02:26] Loading - No properties were available to load.
[22:02:26] Loading - 2 factions loaded from MySQL database.
[22:02:26] Loading - 2 businesses from MySQL database.
[22:02:26] Loading - No Pay n Sprays were available to load.
[22:02:26] Loading - No Toll Booths were available to load.
[22:02:26] Loading - No rental vehicles were available to load.
[22:02:26] Loading - No faction vehicles were available to load.
[22:02:26] Loading - No dynamic doors were available to load.
[22:02:26] Loading - No property garages were available to load.
[22:02:26] Loading - No XMR data was available to load.
[22:02:26] Loading - No XMR data was available to load.
[22:02:26] Loading - No Objects were available to load.
[22:02:26] Loading - 1 entrances were loaded.
[22:02:26] Loading - Nema town banke.
[22:02:26] Loading - Nema dinamicnih vrata.
[22:02:31] [connection] incoming connection: 178.236.95.105:58174 id: 0
[22:02:31] [join] Salesman_Dev has joined the server (0:178.236.95.105)
[22:02:34] [DEBUG] Callback 'LoadPlayerData' called for Salesman_Dev
[22:02:34] [CONNECTION] Salesman_Dev (DBID: 18) logged in. IP: 178.236.95.105
[22:02:34] [DEBUG][OnLoadPlayerWeapons] Player has no weapons. (Salesman_Dev)
[22:02:34] [DEBUG] Salesman_Dev has no fines to load...
[22:02:36] Loading - 0 furnitures were loaded.
[22:02:40] Player [Salesman_Dev] sent command: /cargojob
[22:03:03] Player [Salesman_Dev] sent command: /gotopoint 0 2743.3115 -2454.4939 13.8623
[22:03:07] Player [Salesman_Dev] sent command: /cargojob
[22:03:14] Player [Salesman_Dev] sent command: /loadcrate
[22:03:15] Player [Salesman_Dev] sent command: /loadcrates
[22:03:18] [debug] Run time error 4: "Array index out of bounds"
[22:03:18] [debug]  Attempted to read/write array element at index 561891 in array of size 2000
[22:03:18] [debug] AMX backtrace:
[22:03:18] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:21] [debug] Run time error 4: "Array index out of bounds"
[22:03:21] [debug]  Attempted to read/write array element at index 561891 in array of size 2000
[22:03:21] [debug] AMX backtrace:
[22:03:21] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:24] [debug] Run time error 4: "Array index out of bounds"
[22:03:24] [debug]  Attempted to read/write array element at index 561891 in array of size 2000
[22:03:24] [debug] AMX backtrace:
[22:03:24] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:27] [debug] Run time error 4: "Array index out of bounds"
[22:03:27] [debug]  Attempted to read/write array element at index 561891 in array of size 2000
[22:03:27] [debug] AMX backtrace:
[22:03:27] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:30] [debug] Run time error 4: "Array index out of bounds"
[22:03:30] [debug]  Attempted to read/write array element at index 561891 in array of size 2000
[22:03:30] [debug] AMX backtrace:
[22:03:30] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:33] [debug] Run time error 4: "Array index out of bounds"
[22:03:33] [debug]  Attempted to read/write array element at index 561891 in array of size 2000
[22:03:33] [debug] AMX backtrace:
[22:03:33] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:36] [debug] Run time error 4: "Array index out of bounds"
[22:03:36] [debug]  Attempted to read/write array element at index 561891 in array of size 2000
[22:03:36] [debug] AMX backtrace:
[22:03:36] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:39] [debug] Run time error 4: "Array index out of bounds"
[22:03:39] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:03:39] [debug] AMX backtrace:
[22:03:39] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:42] [debug] Run time error 4: "Array index out of bounds"
[22:03:42] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:03:42] [debug] AMX backtrace:
[22:03:42] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:45] [debug] Run time error 4: "Array index out of bounds"
[22:03:45] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:03:45] [debug] AMX backtrace:
[22:03:45] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:48] [debug] Run time error 4: "Array index out of bounds"
[22:03:48] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:03:48] [debug] AMX backtrace:
[22:03:48] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:51] [debug] Run time error 4: "Array index out of bounds"
[22:03:51] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:03:51] [debug] AMX backtrace:
[22:03:51] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:55] [debug] Run time error 4: "Array index out of bounds"
[22:03:55] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:03:55] [debug] AMX backtrace:
[22:03:55] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:03:58] [debug] Run time error 4: "Array index out of bounds"
[22:03:58] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:03:58] [debug] AMX backtrace:
[22:03:58] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:01] [debug] Run time error 4: "Array index out of bounds"
[22:04:01] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:04:01] [debug] AMX backtrace:
[22:04:01] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:04] [debug] Run time error 4: "Array index out of bounds"
[22:04:04] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:04:04] [debug] AMX backtrace:
[22:04:04] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:07] [debug] Run time error 4: "Array index out of bounds"
[22:04:07] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:04:07] [debug] AMX backtrace:
[22:04:07] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:10] [debug] Run time error 4: "Array index out of bounds"
[22:04:10] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:04:10] [debug] AMX backtrace:
[22:04:10] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:13] [debug] Run time error 4: "Array index out of bounds"
[22:04:13] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:04:13] [debug] AMX backtrace:
[22:04:13] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:16] [debug] Run time error 4: "Array index out of bounds"
[22:04:16] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:04:16] [debug] AMX backtrace:
[22:04:16] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:19] [debug] Run time error 4: "Array index out of bounds"
[22:04:19] [debug]  Attempted to read/write array element at index 561892 in array of size 2000
[22:04:19] [debug] AMX backtrace:
[22:04:19] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:22] [debug] Run time error 4: "Array index out of bounds"
[22:04:22] [debug]  Attempted to read/write array element at index 561893 in array of size 2000
[22:04:22] [debug] AMX backtrace:
[22:04:22] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:25] [debug] Run time error 4: "Array index out of bounds"
[22:04:25] [debug]  Attempted to read/write array element at index 561893 in array of size 2000
[22:04:25] [debug] AMX backtrace:
[22:04:25] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:28] [debug] Run time error 4: "Array index out of bounds"
[22:04:28] [debug]  Attempted to read/write array element at index 561893 in array of size 2000
[22:04:28] [debug] AMX backtrace:
[22:04:28] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:31] [debug] Run time error 4: "Array index out of bounds"
[22:04:31] [debug]  Attempted to read/write array element at index 561893 in array of size 2000
[22:04:31] [debug] AMX backtrace:
[22:04:31] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:34] [debug] Run time error 4: "Array index out of bounds"
[22:04:34] [debug]  Attempted to read/write array element at index 561893 in array of size 2000
[22:04:34] [debug] AMX backtrace:
[22:04:34] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:34] ** Warning: Directory "money_logs/" doesn't exist.
[22:04:37] [debug] Run time error 4: "Array index out of bounds"
[22:04:37] [debug]  Attempted to read/write array element at index 561893 in array of size 2000
[22:04:37] [debug] AMX backtrace:
[22:04:37] [debug] #0 0019a7e4 in public RefreshPlayer () in ls-rp.amx
[22:04:39] [CONNECTION] Salesman_Dev (DBID: 18) disconnected.
[22:04:39] [part] Salesman_Dev has left the server (0:1)
[22:04:39] [LogPlayerAction] Logged '2019-12-3 22:04:39 Disconnected by Quitting' for Player DBID 0
[22:04:47] [connection] incoming connection: 178.236.95.105:61131 id: 0
[22:04:47] [join] Salesman_Dev has joined the server (0:178.236.95.105)
[22:04:50] [DEBUG] Callback 'LoadPlayerData' called for Salesman_Dev
[22:04:50] [CONNECTION] Salesman_Dev (DBID: 18) logged in. IP: 178.236.95.105
[22:04:50] [DEBUG][OnLoadPlayerWeapons] Player has no weapons. (Salesman_Dev)
[22:04:50] [DEBUG] Salesman_Dev has no fines to load...
[22:04:52] Player [Salesman_Dev] sent command: /jobhelp
[22:04:55] Player [Salesman_Dev] sent command: /cargojob
[22:07:03] [CONNECTION] Salesman_Dev (DBID: 18) disconnected.
[22:07:03] [part] Salesman_Dev has left the server (0:1)
[22:07:03] [LogPlayerAction] Logged '2019-12-3 22:07:03 Disconnected by Quitting' for Player DBID 0
Code:
Server:RefreshPlayer()
{
	foreach(new i : Player){
		if (PlayerData[i][pCheckpoint] && PlayerData[i][pCheckpoint] != WEAPON_ORDER_NUMBER){
			new cp = PlayerData[i][pCheckpoint];
			if(!IsPlayerInRangeOfPoint(i, 2.0, PropertyData[cp][propertyExterior][0], PropertyData[cp][propertyExterior][1], PropertyData[cp][propertyExterior][2])){
				PlayerData[i][pCheckpoint] = false;
				DisablePlayerCheckpoint(i);
			}
		}
	}
	return true;
}
Coox is offline   Reply With Quote
Old 04/12/2019, 11:51 AM   #12
IzadorO
Huge Clucker
 
IzadorO's Avatar
 
Join Date: Feb 2015
Location: Scotland, Glasgow
Posts: 201
Reputation: 17
Default Re: Crash on editing objects

cp = PlayerData[i][pCheckpoint] must be out of bounds when used. Run a check to make sure it isn't before using it.
IzadorO is offline   Reply With Quote
Old 04/12/2019, 12:05 PM   #13
CXdur
Big Clucker
 
CXdur's Avatar
 
Join Date: Jun 2014
Location: Norway
Posts: 57
Reputation: 6
Default Re: Crash on editing objects

Code:
if(!IsPlayerInRangeOfPoint(i, 2.0, PropertyData[cp][propertyExterior][0], PropertyData[cp][propertyExterior][1], PropertyData[cp][propertyExterior][2])){
Quote:
Attempted to read/write array element at index 561893 in array of size 2000
Could this be the one that is out of bounds? Is the size of the propertydata array 2000? What does the CP ID (PlayerData[i][pCheckpoint]) look like (what is its range)?
CXdur is offline   Reply With Quote
Old 04/12/2019, 05:42 PM   #14
Coox
Little Clucker
 
Coox's Avatar
 
Join Date: Feb 2018
Posts: 34
Reputation: 0
Default Re: Crash on editing objects

Quote:
Originally Posted by CXdur View Post
Code:
if(!IsPlayerInRangeOfPoint(i, 2.0, PropertyData[cp][propertyExterior][0], PropertyData[cp][propertyExterior][1], PropertyData[cp][propertyExterior][2])){


Could this be the one that is out of bounds? Is the size of the propertydata array 2000? What does the CP ID (PlayerData[i][pCheckpoint]) look like (what is its range)?
PlayerData[i][pCheckpoint] stores the current checkpoint that is placed on the map, I'll run a check to see if its out of bounds.

EDIT: PlayerData[MAX_PLAYERS][E_PROPERTY_DATA]
and propertydata has the array 2000
Coox is offline   Reply With Quote
Old 04/12/2019, 09:22 PM   #15
CXdur
Big Clucker
 
CXdur's Avatar
 
Join Date: Jun 2014
Location: Norway
Posts: 57
Reputation: 6
Default Re: Crash on editing objects

Quote:
Originally Posted by Coox View Post
PlayerData[i][pCheckpoint] stores the current checkpoint that is placed on the map, I'll run a check to see if its out of bounds.

EDIT: PlayerData[MAX_PLAYERS][E_PROPERTY_DATA]
and propertydata has the array 2000
It seems the index (checkpoint ID used) you tried to access the propertydata array with was 561893. Any idea why it would give such a value? You should add a check to prevent it from accessing invalid indexes, but you should also figure out the cause as to why it chose such a number to begin with.

Code:
PlayerData[i][pCheckpoint]
How is this set? Could you share code?
CXdur is offline   Reply With Quote
Old 05/12/2019, 08:15 AM   #16
Coox
Little Clucker
 
Coox's Avatar
 
Join Date: Feb 2018
Posts: 34
Reputation: 0
Default Re: Crash on editing objects

PlayerData[MAX_PLAYERS][pCheckpoint] and it stays like that.
Coox is offline   Reply With Quote
Old 05/12/2019, 04:56 PM   #17
CXdur
Big Clucker
 
CXdur's Avatar
 
Join Date: Jun 2014
Location: Norway
Posts: 57
Reputation: 6
Default Re: Crash on editing objects

Quote:
Originally Posted by Coox View Post
PlayerData[MAX_PLAYERS][pCheckpoint] and it stays like that.
Code:
new cp = PlayerData[i][pCheckpoint]; // used to index checkpoints for propertydata
	if(!IsPlayerInRangeOfPoint(i, 2.0, PropertyData[cp][propertyExterior][0], PropertyData[cp][propertyExterior][1], 
            PropertyData[cp][propertyExterior][2])){
	    PlayerData[i][pCheckpoint] = false; // set to false
I just noticed this. How come you use pCheckpoint as a number first and then as a boolean? Maybe use a guard somehow, such as -1 if the player isn't in any checkpoint? Then skip that part if the player is not in any valid checkpoint?

I still don't understand how it got numbers such as 561893 but correcting this is probably a good start.
CXdur is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
crash on editing objects Coox Client Support 0 02/12/2019 09:03 AM
Editing objects and toy system PaulDinam Scripting Help 0 30/06/2012 11:16 AM
No Objects after Editing Igdirli 76 Help Archive 9 28/02/2010 03:35 PM
Character Editing, 3D mapping editing, skin texture editing Pessetti Everything and Nothing 3 18/07/2009 10:03 PM


All times are GMT. The time now is 12:16 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.