[HELP] Player id 0 and 1 difference?
#1

Hello,

in my mode i have for example skin changer. Player go to pickup and buy any kind of skin.
I have save system too, so if player buy skin id 1 and die or relog he still have skin id 1.
When i test it, it works perfect for me. But iam player id 0, the wierd thing is that when join
another player (id 1), it doesnt work for the player. Player still spawn with skin that he choose in
onplayerrequestclass...


Is there any difference between players IDs ? Do i need to define something for server know that is another player?
Why my code does work for me and doesnt work for other players?

Thanks.
Reply
#2

Can you show the code? We can't do anything without you posting the code. Shwo us the code where you save and load skin.
Reply
#3

There is no anything that could be wrong.

i just use y_ini save system like

Код:
enum pInfo
{
    pSkin
}

public OnPlayerSpawn(playerid)
{

	SetPlayerSkin(playerid,PlayerInfo[playerid][pSkin]);

}
and save it in OnPlayerDissconect..

Код:
INI_WriteInt(file,"Skin",PlayerInfo[playerid][pSkin]);
and load it ..

Код:
forward LoadUser_data(playerid,name[],value[]);
public LoadUser_data(playerid,name[],value[])
{

    INI_Int("Skin", PlayerInfo[playerid][pSkin]);
}
ect .


Like i said it works for me. But it doesnt work for other players so iam confused why the code does not response same for anyone?

For example when i use cmd /drink wich is ApplyAnimation and use timer for 10 second .. I do the animation for 10 second and after 10 second it is disabled so i can go away and move (TogglePlayerControllable(playerid,1). But when other player do the same thing /drink, his animation is after 10 seconds disabled but he cant move from the place where he did / drink.. The code is same for both players. Player with id 0 and player with id 1. Why it is different?

I know there could be some mistakes in the code but ... How is it possbile that my code react different way to player with id 0 and player with id 1 ?
Reply
#4

PHP код:
new PlayerInfo[MAX_PLAYERS][pInfo]; 
Do you have this line under enum?

Are you getting this problem only with Saving/Loading or all the commands?

EDIT: Never mind You probably do. Try updating your server files.
Reply
#5

Quote:
Originally Posted by DarkSkull
Посмотреть сообщение
PHP код:
new PlayerInfo[MAX_PLAYERS][pInfo]; 
Do you have this line under enum?
Yes, this is what i use. The good thing is that it loads all players stats, position and weapons correctly.
The problem is with the skin...
Reply
#6

Either your script is crashing somewhere, or there's some problem in your code before the Players skin is being set. Post the whole loading and saving code, With the OnPlayerSpawn too. It would help!
Reply
#7

Well I found the problem ... It's becasue i use this command /setskin :

Код:
CMD:setskin(playerid, params[])
{
     new name[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], id, skinid, string[128];
     if(!IsPlayerAdmin(playerid)) return 0;
     if(sscanf(params, "ui", id, skinid)) return SendClientMessage(playerid, -1, "USAGE: /setskin [playerid] [skinid]");
     GetPlayerName(playerid, name, MAX_PLAYER_NAME);
     GetPlayerName(id, targetname, MAX_PLAYER_NAME);
     if(id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1, "Player not connected!");
     SetPlayerSkin(id, skinid);
     format(string, 128, "RCON Admin %s(%d) has set your skinid to %i", name, playerid, skinid);
     SendClientMessage(id, -1, string);
     format(string, 128, "You set %s(%d) skin to skinid %i", targetname, id, skinid);
     SendClientMessage(playerid, -1, string);
     return 1;
}
When i use this on player, players skin is not saved becasuse i dont use PlayerInfo[playerid][pSkin] = X;
What should i use instead of X in this case?

And if i set skin example 250 to player with id 1, and player id 1 kill player id 0, the player id 0 get the same skin like player id 1 (skin 250) Wtf

I copied this command.
Reply
#8

Set it to skin id.

That is because you are setting the skin of the player who is using the command and not the id of the player who is being affected. You should use:
PHP код:
PlayerInfo[id][pSkin] = skinid// Here, The 'id' is id of the player who's skin is being changed. So we take that player's id and set the skin value. 
Here's the updated command.
PHP код:
CMD:setskin(playeridparams[])
{
     new 
name[MAX_PLAYER_NAME], targetname[MAX_PLAYER_NAME], idskinidstring[128];
     if(!
IsPlayerAdmin(playerid)) return 0;
     if(
sscanf(params"ui"idskinid)) return SendClientMessage(playerid, -1"USAGE: /setskin [playerid] [skinid]");
     
GetPlayerName(playeridnameMAX_PLAYER_NAME);
     
GetPlayerName(idtargetnameMAX_PLAYER_NAME);
     if(
id == INVALID_PLAYER_ID) return SendClientMessage(playerid, -1"Player not connected!");
     
SetPlayerSkin(idskinid);
     
format(string128"RCON Admin %s(%d) has set your skinid to %i"nameplayeridskinid);
     
SendClientMessage(id, -1string);
     
format(string128"You set %s(%d) skin to skinid %i"targetnameidskinid);
     
SendClientMessage(playerid, -1string);
     
PlayerInfo[id][pSkin] = skinid;
     return 
1;

Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)