Help please SOLVED BY JEFRRY!!! :D:D:D
#1

Hey guys
The color is saving but this is wrong:
my color is saved as blue.
[IMG=/imageshack/img411/1713/samp028y.png][/IMG]

Uploaded with ImageShack.us

I'm uchiha and my friend is jorambo on that picture.
Well. I see my name as purple. That suposed to be blue.
Jorambo sees that it is blue. But my problem is that when you don't have ID 0 you see your color as anohter color that you logged of with.
only ID 0 can see his own name correctly. But you do can see other people their names correctly.
please help



Код:
#include <a_samp>
#include <Dini>
#define ColorFile 	    		"Colors/%s.ini"
public OnFilterScriptInit()
{
SetTimer("CallConnect",1,0);
return 1;
}
forward CallConnect(playerid);
public CallConnect(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
OnPlayerConnect(i);
}
return 1;
}
public OnPlayerConnect(playerid)
{
 	new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),ColorFile,Name);
	if(!dini_Exists(file)) {
		dini_Create(file);
		dini_IntSet(file,"Color",GetPlayerColor(playerid));
	}
	else if(dini_Exists(file))
	{
	SetPlayerColor(playerid,dini_Int(file,"Color"));
	}
	return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
 	new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),ColorFile,Name);
	dini_IntSet(file,"Color",GetPlayerColor(playerid));
	return 1;
}
Reply
#2

SetPlayerColor is bugged at OnPlayerConnect.
Make a timer of 5s when we connects and let the server set the color then.
Reply
#3

can you please make an example? I understand you for 50% now :P
I don't understand how to create that timer and let the color be setted.
PLease help

Thanks for the fast message btw
Reply
#4

OnPlayerConnect:

pawn Код:
SetTimerEx("ChangeColor", 5000, 0, "d", playerid);

At bottom:
pawn Код:
forward ChangeColor(playerid);
public ChangeColor(playerid)
{
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),ColorFile,Name);
    if(!dini_Exists(file)) {
        dini_Create(file);
        dini_IntSet(file,"Color",GetPlayerColor(playerid));
    }
    else if(dini_Exists(file))
    {
    SetPlayerColor(playerid,dini_Int(file,"Color"));
    }
    return 1;
}
Thats it. Should work. If not, just tell me.

Jeffry.




Edit: My 500th post.
Reply
#5

Alright jefffy. I really respect you know for helping me and taking the time.
I will test it and tell if it works or not.

BTW: gratz with your 500 posts


And to be sure.
When I'm done with adding your stuff this is what I have?
Код:
#include <a_samp>
#include <Dini>
#define ColorFile 	    		"Colors/%s.ini"
public OnFilterScriptInit()
{
SetTimer("CallConnect",1,0);

return 1;
}
forward CallConnect(playerid);
public CallConnect(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
OnPlayerConnect(i);
}
return 1;
}
public OnPlayerConnect(playerid)
{
  SetTimerEx("ChangeColor", 5000, 0, "d", playerid);
 	new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),ColorFile,Name);
	if(!dini_Exists(file)) {
		dini_Create(file);
		dini_IntSet(file,"Color",GetPlayerColor(playerid));
	}
	else if(dini_Exists(file))
	{
	SetPlayerColor(playerid,dini_Int(file,"Color"));
	}
	return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
 	new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),ColorFile,Name);
	dini_IntSet(file,"Color",GetPlayerColor(playerid));
	return 1;
}


forward ChangeColor(playerid);
public ChangeColor(playerid)
{
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),ColorFile,Name);
	if(!dini_Exists(file)) {
		dini_Create(file);
		dini_IntSet(file,"Color",GetPlayerColor(playerid));
	}
	else if(dini_Exists(file))
	{
	SetPlayerColor(playerid,dini_Int(file,"Color"));
	}
	return 1;
}
Reply
#6

You would call it twice, one at OnPlayerConnect (bugged) and then at the timer. Remove this at OnPlayerConnect, like I did:

Код:
#include <a_samp>
#include <Dini>
#define ColorFile 	    		"Colors/%s.ini"
public OnFilterScriptInit()
{
SetTimer("CallConnect",1,0); 

return 1;
}
forward CallConnect(playerid);
public CallConnect(playerid)
{
for(new i = 0; i < MAX_PLAYERS; i++)
{
OnPlayerConnect(i);
}
return 1;
}
public OnPlayerConnect(playerid)
{
  SetTimerEx("ChangeColor", 5000, 0, "d", playerid);
	return 1;
}


public OnPlayerDisconnect(playerid, reason)
{
 	new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),ColorFile,Name);
	dini_IntSet(file,"Color",GetPlayerColor(playerid));
	return 1;
}


forward ChangeColor(playerid);
public ChangeColor(playerid)
{
new file[100],Name[MAX_PLAYER_NAME]; GetPlayerName(playerid,Name,sizeof(Name)); format(file,sizeof(file),ColorFile,Name);
	if(!dini_Exists(file)) {
		dini_Create(file);
		dini_IntSet(file,"Color",GetPlayerColor(playerid));
	}
	else if(dini_Exists(file))
	{
	SetPlayerColor(playerid,dini_Int(file,"Color"));
	}
	return 1;
}
This should work. Try it out.
Reply
#7

Jeffry.

DID I ALREADY TOLD YOU HOW FREAKING BRILLIANT YOU ARE?!!!!
YOU ARE THE BEST. THAT MEANS IT IS WORKING!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!


THANKYOU THANK YOU THANKYUUUUUUU!!!!


<3 XD
Reply
#8

No problem.
Makes me happy if I could help you.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)