SA-MP Forums Archive
Need some 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: Need some help. (/showthread.php?tid=527781)



Need some help. - k2rl - 24.07.2014

When i do /setname [ID] name_name it deletes the old player file and creates a new one, but it doesn't include the password of the account.
Is there a way to just change the file name?

(I am learning how to script i'm using the ZGaming Script.)

PHP код:
CMD:setname(playeridparams[])
{
    new 
playerb ,string[128], string2[128], file[64], idxidx2idx3idx4text[MAX_PLAYER_NAME];
       if(!
IsPlayerLoggedIn(playerid)) return SendClientMessage(playeridCOLOR_GREY"You need to login first before using any command.");
       if(
PlayerInfo[playerid][pAdmin] < && !Approve[playerid]) return SendClientMessage(playeridCOLOR_GREY"You are not authorized to use this command.");
    if(
Approve[playerid]) Approve[playerid] = 0;
    if(
sscanf(params"us[24]"playerbtext)) return SendClientMessage(playeridCOLOR_WHITE"USAGE: /setname [playerid] [name]");
    if(
aDuty[playerb]) return SendClientMessage(playeridCOLOR_GREY"You can't set an admin on duty's name.");
    if(!
IsPlayerLoggedIn(playerb)) return SendClientMessage(playeridCOLOR_GREY"Invalid player id.");
    
// Start of detecting space in name
    
new endtemp[32], temp2[32];
    
end strfind(text" ",true);
    if(
end != -1)
    {
        
strmid(temptext0end);
        
format(tempsizeof(temp), "%s_"temp);
        
strdel(text0end);
        
strmid(temp2text1strlen(text));
        
format(text24"");
        
strcat(texttempsizeof(temp));
        
strcat(texttemp2sizeof(temp2));
    }
    
// End of detecting space in name
    
format(stringsizeof(string), "AdmCmd: %s has changed %s's name to %s."RPN(playerid), RPN(playerb), text);
    
format(string2sizeof(string2), " Administrator %s has changed your name to {FF6347}%s{FFFFFF}."RPN(playerid), text);
    
format(filesizeof(file), "users/%s.ini"text);
    if(
dini_Exists(file)) return SendClientMessage(playeridCOLOR_GREY"Name already in use.");
    
idx PlayerInfo[playerb][pBiz];
    
idx2 PlayerInfo[playerb][pHouse];
    
idx3 PlayerInfo[playerb][pVBiz];
    
idx4 PlayerInfo[playerb][pVHouse];
    
format(filesizeof(file), "users/%s.ini"RPNU(playerb));
    
dini_Remove(file);
    
SetPlayerName(playerbtext);
    
PlayerInfo[playerb][pBiz] = idx;
    
format(filesizeof(file), "users/%s.ini"RPNU(playerb));
    
dini_Create(file);
    
SaveChar(playerb);
    
SendAdminMessage(COLOR_DARKRED1string);
    
SendClientMessage(playerbCOLOR_WHITEstring2);
    if(
idx)
    {
        
format(BizInfo[idx][bOwner], 32"%s"text);
          
format(stringsizeof(string), "Business of %s\nBusiness type: %s\n%s"BizInfo[idx][bOwner], RBT(idx), RBS(idx));
        
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITEstring);
    }
    if(
idx2)
    {
         
idx idx2;
        
format(HouseInfo[idx][hOwner], 32"%s"text);
          
format(stringsizeof(string), "{00C0FF}House of %s\nHouse Type: %s\nStatus: %s"HouseInfo[idx][hOwner], HT(idx), RHS(idx));
        
UpdateDynamic3DTextLabelText(HouseInfo[idx][hText], COLOR_WHITEstring);
    }
    if(
idx3)
    {
        
idx idx3;
          
format(BizInfo[idx][bOwner], 32"%s"text);
        
format(stringsizeof(string), "Business of %s\nBusiness type: %s\n%s"BizInfo[idx][bOwner], RBT(idx), RBS(idx));
        
UpdateDynamic3DTextLabelText(BizInfo[idx][bText], COLOR_WHITEstring);
    }
    if(
idx4)
    {
         
idx idx4;
           
format(HouseInfo[idx][hOwner], 32"%s"text);
        
format(stringsizeof(string), "{00C0FF}House of %s\nHouse Type: %s\nStatus: %s"HouseInfo[idx][hOwner], HT(idx), RHS(idx));
        
UpdateDynamic3DTextLabelText(HouseInfo[idx][hText], COLOR_WHITEstring);
    }
    return 
1;




Re: Need some help. - nmader - 24.07.2014

You're kinda SOL (Shit Outta' Luck). There is no way to just rename a file with dini, you have to copy all it's contents over to a new folder. I know you're learning, but when you can change to y_ini or MySQL if you're really looking for a good challenge. Dini is so outdated and slow.


Re: Need some help. - k2rl - 24.07.2014

but when it deletes the old file and creates a new one, how can i add the password?


Re: Need some help. - nmader - 24.07.2014

Load it just as you would any other string, refer to the section that loads the player, I haven't used dini in so long (and I'd rather not learn something practically obsolete).