SA-MP Forums

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

Reply
 
Thread Tools Display Modes
Old 23/07/2017, 03:48 PM   #1
Ebisu
Little Clucker
 
Ebisu's Avatar
 
Join Date: May 2017
Location: Earth
Posts: 22
Reputation: 1
Default What to add

So heres the code.
I know what's the problem here, PlayerInfo's value used in integers, but i don't know how to use it so it can be used with dini_Get or dini_Set.
PHP Code:
stock LoadInventory(playerid)
{
    new 
file[200], name[MAX_PLAYER_NAME];
    
GetPlayerName(playeridnamesizeof(name));
    
format(filesizeof(file), "Inventory/%s.sav"name);

    
PlayerInfo[playerid][Slot[0]] = dini_Get(file"Slot0");
    
PlayerInfo[playerid][Slot[1]] = dini_Get(file"Slot1");
    
PlayerInfo[playerid][Slot[2]] = dini_Get(file"Slot2");
    
PlayerInfo[playerid][Slot[3]] = dini_Get(file"Slot3");
    
PlayerInfo[playerid][Slot[4]] = dini_Get(file"Slot4");
    
PlayerInfo[playerid][Slot[5]] = dini_Get(file"Slot5");
    
PlayerInfo[playerid][Slot[6]] = dini_Get(file"Slot6");
    
PlayerInfo[playerid][Slot[7]] = dini_Get(file"Slot7");
    
PlayerInfo[playerid][Slot[8]] = dini_Get(file"Slot8");
    
PlayerInfo[playerid][Slot[9]] = dini_Get(file"Slot9");
    
PlayerInfo[playerid][Slot[10]] = dini_Get(file"Slot10");
    return 
1;

Ebisu is offline   Reply With Quote
Old 23/07/2017, 04:29 PM   #2
CodeStyle175
Banned
 
Join Date: Apr 2014
Posts: 455
Reputation: 35
Default Re: What to add

PHP Code:
stock LoadInventory(playerid

    new 
file[50], s[24]; 
    
GetPlayerName(playerid,s,24); 
    
format(file,sizeof(file),"Inventory/%s.sav",s); 
    for(new 
i11i++)format(s,sizeof(s),"Slot%d",i),PlayerInfo[playerid][Slot][i] = dini_Get(file,s); 
    return 
1

CodeStyle175 is offline   Reply With Quote
Old 23/07/2017, 04:45 PM   #3
Ebisu
Little Clucker
 
Ebisu's Avatar
 
Join Date: May 2017
Location: Earth
Posts: 22
Reputation: 1
Default Re: What to add

It's the same error that appeared the first time i tried.
Didn't really help.
"error 006: must be assigned to an array"
PHP Code:
/*This line>>*/format(s,sizeof(s),"Slot%d",i),PlayerInfo[playerid][Slot][i] = dini_Get(files); 
Ebisu is offline   Reply With Quote
Old 24/07/2017, 09:30 AM   #4
Ebisu
Little Clucker
 
Ebisu's Avatar
 
Join Date: May 2017
Location: Earth
Posts: 22
Reputation: 1
Default Re: What to add

UP, Help will be appreciated.
Ebisu is offline   Reply With Quote
Old 24/07/2017, 09:33 AM   #5
Xeon™
Banned
 
Join Date: Jul 2017
Location: Earth
Posts: 457
Reputation: 96
Default Re: What to add

never used dini, but it will look like that i guess

PHP Code:
stock LoadInventory(playerid

    new 
file[50], s[24]; 
    
GetPlayerName(playerid,s,24); 
    
format(file,sizeof(file),"Inventory/%s.sav",s); 
    for(new 
i11i++)format(s,sizeof(s),"Slot%d",i),PlayerInfo[playerid][Slot[i]] = strval(dini_Get(file,s)); 
    return 
1

Xeon™ is offline   Reply With Quote
Old 24/07/2017, 09:34 AM   #6
skuller12
Big Clucker
 
Join Date: Feb 2015
Location: Galati, Romania
Posts: 101
Reputation: 0
Default Re: What to add

Code:
format(s, 24, "Slot%d", i),PlayerInfo[playerid][Slot[i]] = dini_Get(file, s);
skuller12 is offline   Reply With Quote
Old 24/07/2017, 10:14 AM   #7
Ebisu
Little Clucker
 
Ebisu's Avatar
 
Join Date: May 2017
Location: Earth
Posts: 22
Reputation: 1
Default Re: What to add

Not working, Maybe give me any ideas to save player's items
Not really wanna use advanced dialogs.
Ebisu is offline   Reply With Quote
Old 24/07/2017, 10:47 AM   #8
Xeon™
Banned
 
Join Date: Jul 2017
Location: Earth
Posts: 457
Reputation: 96
Default Re: What to add

Quote:
Originally Posted by Ebisu View Post
Not working, Maybe give me any ideas to save player's items
Not really wanna use advanced dialogs.
Show me how you defined Slot on PlayerInfo
Xeon™ is offline   Reply With Quote
Old 24/07/2017, 10:50 AM   #9
Ebisu
Little Clucker
 
Ebisu's Avatar
 
Join Date: May 2017
Location: Earth
Posts: 22
Reputation: 1
Default Re: What to add

Thanks for the help anyways, Figured it out myself
Ebisu 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



All times are GMT. The time now is 01:56 PM.


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