color saver/loader zcmd
#1

I tried to create a color saver/loader and it keep returning black. I wanted it to work like if I type:
Код:
	CMD:purple(playerid, params[])
	{
		SetPlayerColor(playerid, COLOR_PURPLE);
		SendClientMessage(playerid, COLOR_LIME, "Your name color successfully change to Purple!");
	}
it set my color purple.

and then when I disconnect it save my color. then when I connect, it set my color back to purple. anyway to do this?
Reply
#2

What type of saving system do you use?
Reply
#3

I use
Код:
#include <a_samp>
#include <irc>
#include <foreach>
#include <rDutils>
#include <dini>
#include <YSI\y_scripting>
#include <YSI\y_ini>
#include <zcmd>
#include <sscanf2>
Reply
#4

anyone?damn it.
Reply
#5

Post your save codes.
Reply
#6

something like this?
Quote:

public loadaccount_user(playerid, name[], value[])
{
INI_String("Password", PlayerAcc[playerid][Pass], 129);
INI_String("Ip", PlayerAcc[playerid][Ip], 16);
INI_Int("BlockPM", PlayerAcc[playerid][BlockPM]);
INI_Int("Hours", PlayerAcc[playerid][hours]);
INI_Int("Minutes", PlayerAcc[playerid][minuteit]);
INI_Int("Seconds", PlayerAcc[playerid][secs]);
INI_Int("Banned", PlayerAcc[playerid][Banned]);
INI_String("AdminWhoBanIt", PlayerAcc[playerid][AdminWhoBanIt], MAX_PLAYER_NAME);
INI_String("Reason", PlayerAcc[playerid][Reason], 12;
INI_String("SecurityQuestion", PlayerAcc[playerid][Question], 129);
INI_String("Answer", PlayerAcc[playerid][Answer], 129);
INI_Int("Cookies", PlayerAcc[playerid][Cookies]);
INI_Int("SaveSkin", PlayerAcc[playerid][SaveSkin]);
INI_Int("UseSkin", PlayerAcc[playerid][UseSkin]);
INI_Int("Jail", PlayerAcc[playerid][Jail]);
INI_Int("Mute", PlayerAcc[playerid][Mute]);
INI_Int("MuteTime", PlayerAcc[playerid][MuteTime]);
INI_Int("Admin", PlayerAcc[playerid][Admin]);
INI_Int("Vip", PlayerAcc[playerid][Vip]);
INI_Int("WantedLevel", PlayerAcc[playerid][WantedLvl]);
if(ServerInfo[ScoreSaving] == 1)
{
INI_Int("Score", PlayerAcc[playerid][Score]);
}
INI_Int("Money", PlayerAcc[playerid][Money]);
INI_Int("Kills", PlayerAcc[playerid][Kills]);
INI_Int("Deaths", PlayerAcc[playerid][Deaths]);
INI_Float("XPos", PlayerAcc[playerid][X]);
INI_Float("YPos", PlayerAcc[playerid][Y]);
INI_Float("ZPos", PlayerAcc[playerid][Z]);
INI_Float("Angle", PlayerAcc[playerid][Ang]);
INI_Int("Interior", PlayerAcc[playerid][Int]);
INI_Int("World", PlayerAcc[playerid][World]);
return 1;
}

Reply
#7

Okay buddy, here you go;
Create a variable in YOUR MAX_PLAYER ENUM like this;

PHP код:
enum pinfo
{
     
// etc...
     
colorstr[32],
    
// etc...
};
new 
PlayerAcc[MAX_PLAYERS][pinfo]; 
PHP код:
// Put it into your OnPlayerSpawn(playerid) callback
public OnPlayerSpawn(playerid)
{
    
// etc...
    
SetPlayerColorEx(playeridPlayerAcc[playerid][colorstr]);
    
// etc...
    
return 1;
}
// When player choose a color, you will make like this;
CMD:purple(playeridparams[])
{
        
SetPlayerColor(playeridCOLOR_PURPLE);
        
format(PlayerAcc[playerid][colorstr],32,"COLOR_PURPLE");
        
SendClientMessage(playeridCOLOR_LIME"Your name color successfully change to Purple!");
        return 
1;
}
    
// Example for you;
CMD:blue(playeridparams[])
{
        
SetPlayerColor(playeridCOLOR_BLUE);
        
format(PlayerAcc[playerid][colorstr],32,"COLOR_BLUE");
        
SendClientMessage(playeridCOLOR_LIME"Your name color successfully change to Blue!");
        return 
1;
}
stock SetPlayerColorEx(playerid,colorstr[])
{
    if(
strcmp(colorstr"COLOR_PURPLE") == 0)
    {
        
SetPlayerColor(playerid,COLOR_PURPLE);
    }
    if(
strcmp(colorstr"COLOR_BLUE") == 0)
    {
        
SetPlayerColor(playerid,COLOR_BLUE);
    }         
    
// Use it with this method for other colors you got in this stock function...
    
return 1;

Reply
#8

Quote:
Originally Posted by trablon
Посмотреть сообщение
Okay buddy, here you go;
Create a variable in YOUR MAX_PLAYER ENUM like this;

PHP код:
enum pinfo
{
     
// etc...
     
colorstr[32],
    
// etc...
};
new 
PlayerAcc[MAX_PLAYERS][pinfo]; 
PHP код:
// Put it into your OnPlayerSpawn(playerid) callback
public OnPlayerSpawn(playerid)
{
    
// etc...
    
SetPlayerColorEx(playeridPlayerAcc[playerid][colorstr]);
    
// etc...
    
return 1;
}
// When player choose a color, you will make like this;
CMD:purple(playeridparams[])
{
        
SetPlayerColor(playeridCOLOR_PURPLE);
        
format(PlayerAcc[playerid][colorstr],32,"COLOR_PURPLE");
        
SendClientMessage(playeridCOLOR_LIME"Your name color successfully change to Purple!");
        return 
1;
}
    
// Example for you;
CMD:blue(playeridparams[])
{
        
SetPlayerColor(playeridCOLOR_BLUE);
        
format(PlayerAcc[playerid][colorstr],32,"COLOR_BLUE");
        
SendClientMessage(playeridCOLOR_LIME"Your name color successfully change to Blue!");
        return 
1;
}
stock SetPlayerColorEx(playerid,colorstr[])
{
    if(
strcmp(colorstr"COLOR_PURPLE") == 0)
    {
        
SetPlayerColor(playerid,COLOR_PURPLE);
    }
    if(
strcmp(colorstr"COLOR_BLUE") == 0)
    {
        
SetPlayerColor(playerid,COLOR_BLUE);
    }         
    
// Use it with this method for other colors you got in this stock function...
    
return 1;

what about OnPlayerDisconnect
Reply
#9

Quote:
Originally Posted by TenTen
Посмотреть сообщение
what about OnPlayerDisconnect
Just check it carefully.

format(PlayerAcc[playerid][colorstr],32,"COLOR_PURPLE");
Reply
#10

Why do you store a string when you don't even need it and just use it to compare? You are wasting more memory than if it was an integer.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)