SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 09/10/2012, 11:57 PM   #1
RLGaming
Huge Clucker
 
Join Date: Dec 2011
Posts: 352
Reputation: 35
Default whats wrong with this loading code?

I have this:
Quote:
LoadGarages() {

if(!fexist("Garages/garages.cfg")) return 1;

new
szFileStr[1024],
File: iFileHandle = fopen("Garages/garages.cfg", io_read),
iIndex;

while(iIndex < MAX_GARAGES && fread(iFileHandle, szFileStr)) {
if(!sscanf(szFileStr, "p<|>is[24]ffffffffiiii",
arrGarage[iIndex][b_iInteriorID],
arrGarage[iIndex][b_szOwner],
arrGarage[iIndex][b_fExteriorPos][0],
arrGarage[iIndex][b_fExteriorPos][1],
arrGarage[iIndex][b_fExteriorPos][2],
arrGarage[iIndex][b_fExteriorPos][3],
arrGarage[iIndex][b_fInteriorPos][0],
arrGarage[iIndex][b_fInteriorPos][1],
arrGarage[iIndex][b_fInteriorPos][2],
arrGarage[iIndex][b_fInteriorPos][3],
arrGarage[iIndex][b_iValue],
arrGarage[iIndex][b_iFee],
arrGarage[iIndex][b_iSafeMoney],
arrGarage[iIndex][b_iLocked])) {

if(!isnull(arrGarage[iIndex][b_szOwner])) format(szFileStr, sizeof(szFileStr), "Garage\n%s\nOwned by %s\nID: %d", ((arrGarage[iIndex][b_iLocked]) ? ("{FF0000}Closed{33AA33}") : ("{E8A831}Open{33AA33}")), arrGarage[iIndex][b_szOwner], iIndex);
else format(szFileStr, sizeof(szFileStr), "{E8A831}This garage is for sale for $%d!\n{33AA33}/buygarage to purchase.\nID: %d", arrGarage[iIndex][b_iValue], iIndex);
if(arrGarage[iIndex][b_iFee] > 0)
{
if(!isnull(arrGarage[iIndex][b_szOwner])) format(szFileStr, sizeof(szFileStr), "Garage\n%s\nEntrance fee: $%i\nOwned by %s\nID: %d", ((arrGarage[iIndex][b_iLocked]) ? ("{FF0000}Closed{33AA33}") : ("{E8A831}Open{33AA33}")), arrGarage[iIndex][b_iFee], arrGarage[iIndex][b_szOwner], iIndex);
}
arrGarage[iIndex][b_iPickupID] = CreateDynamicPickup(1239, 23, arrGarage[iIndex][b_fExteriorPos][0], arrGarage[iIndex][b_fExteriorPos][1], arrGarage[iIndex][b_fExteriorPos][2], .worldid = 0, .interiorid = 0);
arrGarage[iIndex][b_tLabelID] = CreateDynamic3DTextLabel(szFileStr, COLOR_GREEN, arrGarage[iIndex][b_fExteriorPos][0], arrGarage[iIndex][b_fExteriorPos][1], arrGarage[iIndex][b_fExteriorPos][2] + 0.5,30.0, .testlos = 1, .streamdistance = 30.0, .worldid = 0, .interiorid = 0);
++iIndex;
}
}
return fclose(iFileHandle);
}
and under my OnGameModeInit the LoadGarages();

But they never load? Its using the exact same loading as my business system but obviously its loading the garage info, it doesnt give me any warnings or errors and my business loading system works but not this..

on the .cfg file the garages are there from when I created them but they wont load

+rep
__________________
scripter & mapper
RLGaming is offline   Reply With Quote
Old 10/10/2012, 01:58 AM   #2
diego_p11
Big Clucker
 
Join Date: Aug 2011
Posts: 70
Reputation: 5
Default Re: whats wrong with this loading code?

try to make it on a filterscript, it might work.
once on ig you can do /rcon loadfs [name of filterscript] to load it.
and if it doesnt work you can try /rcon reloadfs [name]

if it worked give +rep
diego_p11 is offline   Reply With Quote
Old 10/10/2012, 08:01 AM   #3
RLGaming
Huge Clucker
 
Join Date: Dec 2011
Posts: 352
Reputation: 35
Default Re: whats wrong with this loading code?

What do you mean indent?
Quote:
enum eGarageData {
b_iInteriorID,
b_szOwner[MAX_PLAYER_NAME],
Float: b_fExteriorPos[4],
Float: b_fInteriorPos[4],
Text3D: b_tLabelID,
b_iValue,
b_iSafeMoney,
b_iPickupID,
b_iFee,
b_iLocked
};
Quote:
SaveGarages() {

new
szFileStr[1024],
File: fHandle = fopen("Garages/garages.cfg", io_write);

for(new iIndex; iIndex < MAX_GARAGES; iIndex++) {
format(szFileStr, sizeof(szFileStr),"%s|%i|%.2f|%.2f|%.2f|%.2f|%.2f| %.2f|%.2f|%.2f|%i|$%i|%i|%i\r\n",
arrGarage[iIndex][b_szOwner],
arrGarage[iIndex][b_iInteriorID],
arrGarage[iIndex][b_fExteriorPos][0],
arrGarage[iIndex][b_fExteriorPos][1],
arrGarage[iIndex][b_fExteriorPos][2],
arrGarage[iIndex][b_fExteriorPos][3],
arrGarage[iIndex][b_fInteriorPos][0],
arrGarage[iIndex][b_fInteriorPos][1],
arrGarage[iIndex][b_fInteriorPos][2],
arrGarage[iIndex][b_fInteriorPos][3],
arrGarage[iIndex][b_iValue],
arrGarage[iIndex][b_iFee],
arrGarage[iIndex][b_iSafeMoney],
arrGarage[iIndex][b_iLocked]
);
fwrite(fHandle, szFileStr);
}
fclose(fHandle);
return 1;
}
__________________
scripter & mapper
RLGaming is offline   Reply With Quote
Old 10/10/2012, 08:03 AM   #4
Faisal_khan
High-roller
 
Faisal_khan's Avatar
 
Join Date: Feb 2012
Location: Nagpur, India
Posts: 1,826
Reputation: 208
Default Re: whats wrong with this loading code?

Use pawn tags to paste code not qoute tags.
__________________
Not a SAMP Dev. anymore.
Hire me for teaching any programming langauge.
Interested? Hit me up on Skype: pfk3325
Faisal_khan is offline   Reply With Quote
Old 10/10/2012, 08:59 AM   #5
RLGaming
Huge Clucker
 
Join Date: Dec 2011
Posts: 352
Reputation: 35
Default Re: whats wrong with this loading code?

Thanks for the help, fixed my problem! #sarcasm

You can still see it so I don't give a shit
__________________
scripter & mapper
RLGaming is offline   Reply With Quote
Old 10/10/2012, 12:05 PM   #6
RLGaming
Huge Clucker
 
Join Date: Dec 2011
Posts: 352
Reputation: 35
Default Re: whats wrong with this loading code?

Bump! Only post if you can help
__________________
scripter & mapper
RLGaming is offline   Reply With Quote
Old 10/10/2012, 01:42 PM   #7
Kwarde
High-roller
 
Kwarde's Avatar
 
Join Date: Nov 2009
Location: The Netherlands
Posts: 2,516
Reputation: 1635
Default Re: whats wrong with this loading code?

@RLGaming: As mentioned a several times before: Please post a good looking code, eg. pastebin (as told already). Perhaps you still didn't get it so I'll just repeat it: Right now it's harder to read. With the better intending (with tabs) and highlighting, it'll be better to read and then we might be able to help.
__________________
Do not click on this URL -It is secret information
RIP Slayer 1981-2019 \m/
Kwarde is offline   Reply With Quote
Old 10/10/2012, 03:25 PM   #8
RLGaming
Huge Clucker
 
Join Date: Dec 2011
Posts: 352
Reputation: 35
Default Re: whats wrong with this loading code?

Can anyone help?
http://pastebin.com/deBaR1HL

If your not gonna help, don't bother posting. Leave me a visitor message if you want some banter.

And to people that are willing to help, I don't receive any warnings or errors.
__________________
scripter & mapper
RLGaming 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
Whats Wrong with my code? stormchaser206 Scripting Help 2 01/02/2012 09:37 PM
Whats wrong with this code? vent Scripting Help 2 27/11/2011 05:18 AM
whats wrong with saving / loading?.. Gh0sT_ Help Archive 9 27/10/2010 09:02 PM
Whats wrong with loading from a file? ÄitisOnHuora Help Archive 3 15/03/2010 01:51 PM
Whats wrong with this code? killdahobo99 Help Archive 14 19/07/2009 05:24 AM


All times are GMT. The time now is 02:51 PM.


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