dini help
#1

Why this code doesnt work?
If the players_name.ini file doesnt exist in players folder then give him skin id 26 and sends message.
If the players_name.ini file does exist in players folder then load saved players pos from .ini file.
The file in the folder exist but it keeps giving me skin 26 and sends message.
Код:
public OnPlayerSpawn(playerid)
{

new player[MAX_PLAYER_NAME];
   GetPlayerName(playerid, player, sizeof(player));
   if(!dini_Exists("players/%s.ini"))
   {
   SetPlayerSkin(playerid, 26);
   SendClientMessage(playerid, COLOR_WHITE, "Welcome new player!");
   }
   if(dini_Exists("players/%s.ini"))
   {
   SendClientMessage(playerid, COLOR_WHITE, "Welcome back!");
   SetPlayerPos(playerid,positionx,positiony,positionz);
   }

   return 1;
}
Reply
#2

pawn Код:
#define Playerfile "players/%s.ini" // Put this under your defines

public OnPlayerSpawn(playerid)
{

   new name [MAX_PLAYER_NAME], file[128];
   GetPlayerName(playerid, name, sizeof(name));
   format(file, sizeof(file), Playerfile, name);
   if(!fexist(file))
   {
   SetPlayerSkin(playerid, 26);
   SendClientMessage(playerid, COLOR_WHITE, "Welcome new player!");
   }
   if(fexist(file))
   {
   SendClientMessage(playerid, COLOR_WHITE, "Welcome back!");
   SetPlayerPos(playerid,positionx,positiony,positionz);
   }

   return 1;
}
Not sure if this is gonna work, but atleast worth a try
Reply
#3

Doesnt work.. gives me skin 26 and message!
Reply
#4

Uhm, try to put the if(fexist(file)) above the if(!fexist(file)). Also, what skin would it give him if he/she spawns?
Is it the skin 26, or a different skin?
Reply
#5

if the .ini file exists then it loads player pos. from it SetPlayerPos(playerid,positionx,positiony,position z);. If the file doesn't exist then give player skin 26.
Reply
#6

But what skin does he/she gets when the file DOES exist
Reply
#7

If the file exists he/she can select from selection menu. But latter i will make skin saving.
Reply
#8

I found the problem. It was in the .ini files name. If my game name is NAME_NAME it saves it NAME_00NAME.ini. how to save in my name?
This is how my server creates it.
Код:
dini_Create(FileStats(playerid));
Reply
#9

Quote:
Originally Posted by krisis32
Посмотреть сообщение
Why this code doesnt work?
If the players_name.ini file doesnt exist in players folder then give him skin id 26 and sends message.
If the players_name.ini file does exist in players folder then load saved players pos from .ini file.
The file in the folder exist but it keeps giving me skin 26 and sends message.
pawn Код:
public OnPlayerSpawn(playerid)
{

new player[MAX_PLAYER_NAME];
   GetPlayerName(playerid, player, sizeof(player));
   if(!dini_Exists("players/%s.ini"))
   {
   SetPlayerSkin(playerid, 26);
   SendClientMessage(playerid, COLOR_WHITE, "Welcome new player!");
   }
   if(dini_Exists("players/%s.ini"))
   {
   SendClientMessage(playerid, COLOR_WHITE, "Welcome back!");
   SetPlayerPos(playerid,positionx,positiony,positionz);
   }

   return 1;
}
OMG You forgot to format the string!! It will seek for "%s.ini" not for "YourName.ini"

pawn Код:
public OnPlayerSpawn(playerid)
{
   new player[MAX_PLAYER_NAME];
   GetPlayerName(playerid, player, sizeof(player));
   new string[256]; //new line added
   format(string,sizeof(string), "players/%s.ini", player); //
   if(!dini_Exists(string)) //Line edited
   {
       SetPlayerSkin(playerid, 26);
       SendClientMessage(playerid, COLOR_WHITE, "Welcome new player!");
   }
   else //Also edited this. Pawno likes this much more than using 2 "if". It'll be more fast.
   {
       SendClientMessage(playerid, COLOR_WHITE, "Welcome back!");
       SetPlayerPos(playerid,positionx,positiony,positionz);
   }
   return 1;
}
TIP: use "pawn" and "/pawn" instead of "code" and "/code"
Reply
#10

Ok, thanks!
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)