SA-MP Forums Archive
dini 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: dini help (/showthread.php?tid=261725)



dini help - krisis32 - 14.06.2011

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;
}



Re: dini help - Wesley221 - 15.06.2011

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


Re: dini help - krisis32 - 15.06.2011

Doesnt work.. gives me skin 26 and message!


Re: dini help - Wesley221 - 15.06.2011

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?


Re: dini help - krisis32 - 15.06.2011

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.


Re: dini help - Wesley221 - 15.06.2011

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


Re: dini help - krisis32 - 15.06.2011

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


Re: dini help - krisis32 - 15.06.2011

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));



Re: dini help - Sasino97 - 15.06.2011

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"


Re: dini help - krisis32 - 15.06.2011

Ok, thanks!