spawning a player
#1

hello guys, I am making a tutorial system for my server, and this is my ondialogresponse code:
Код:
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
	switch(dialogid)
	{
        case DIALOG_REGISTER:
		{
            if(!response) Kick(playerid);
            else
			{
			if(!strlen(inputtext))
			{
   				SendClientMessage(playerid, COLOR_SYS, "* [SERVER]: {FFFFFF}You have to enter your desired password in order to register.");
       			return ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_PASSWORD, "{00F1F1}Welcome To Anynoymous Creek Roleplay!", "{FFFFFF}I see it's your first time here! Let me introduce myself, my name is {00F1F1}Cesar!\n{FF4747}*You are going to play on a server, where the roleplay begins from the registration!*\n\n{E6C700}Please enter your desired password below:", "Begin", "Quit");
          	}
           	WP_Hash(PlayerInfo[playerid][Password], 129, inputtext);
           	new INI:file = INI_Open(UserPath(playerid));
           	INI_SetTag(file, "PlayerInfo");
           	INI_WriteString(file, "Password", PlayerInfo[playerid][Password]);
           	INI_WriteInt(file, "AdminLevel", 0);
           	INI_WriteInt(file, "VIPLevel", 0);
           	INI_WriteInt(file, "Money", 0);
           	INI_WriteInt(file, "Score", 0);
           	INI_WriteInt(file, "Kills", 0);
           	INI_WriteInt(file, "Deaths", 0);
           	INI_WriteInt(file, "Faction", 0);
			INI_WriteInt(file, "Facrank", 0);
			INI_WriteInt(file, "Facleader", 0);
           	INI_Close(file);
           	SendClientMessage(playerid, COLOR_SYS, "* [SERVER]: {FFFFFF}You have successfully created an account at {00F1F1}Palomino Creek Roleplay!");
           	SendClientMessage(playerid, COLOR_SYS, "* [SERVER]: {FFFFFF}For more help you can use {00F1F1}/cmds, /help, /map.");
           	SendClientMessage(playerid, COLOR_GOLD, " *[TIP] - If spotted a hacker, or found a bug use /report to request admin assistance.");
           	PlayerInfo[playerid][LoggedIn] = true;
           	TogglePlayerSpectating(playerid, true);
           	SendClientMessage(playerid, -1, "");
           	SendClientMessage(playerid, -1, "");
           	SendClientMessage(playerid, -1, "");
           	
           	SendClientMessage(playerid,COLOR_LIGHTBLUE,"Before we will start playing I want you to go through a quick tutorial.");
           	TextDrawHideForPlayer(playerid, Text:Textdraw7);
			TextDrawHideForPlayer(playerid, Text:Textdraw8);
			TextDrawHideForPlayer(playerid, Text:Textdraw9);
			TextDrawHideForPlayer(playerid, Text:Textdraw10);
			TextDrawHideForPlayer(playerid, Text:Textdraw11);
			TextDrawHideForPlayer(playerid, Text:Textdraw12);
			TextDrawHideForPlayer(playerid, Text:Textdraw13);
			TextDrawHideForPlayer(playerid, Text:Textdraw14);
			TextDrawHideForPlayer(playerid, Text:Textdraw15);
			TextDrawHideForPlayer(playerid, Text:Textdraw16);
			TextDrawHideForPlayer(playerid, Text:Textdraw17);
			TextDrawHideForPlayer(playerid, Text:Textdraw18);
			TextDrawHideForPlayer(playerid, Text:Textdraw19);
			TextDrawHideForPlayer(playerid, Text:Textdraw20);
			TextDrawHideForPlayer(playerid, Text:Textdraw21);
			SetTimerEx("OnPlayerInTutorial",6000,0,"ii",playerid,1);
           	return 1;
       }
   }
and here below is the tutorial code
Код:
forward OnPlayerInTutorial(playerid,step);
public OnPlayerInTutorial(playerid,step)
{
    switch(step)
    {
        case 1:
        {
            //2nd message
            SendClientMessage(playerid,-1,"here the text");
            SetTimerEx("OnPlayerInTutorial",5000,0,"ii",playerid,2);
            return 1;
        }
        case 2:
        {
            //3rd message
            SendClientMessage(playerid,-1,"here the text");
            SetTimerEx("OnPlayerInTutorial",5000,0,"ii",playerid,3);
            return 1;
        }
        case 3:
        {
            SendClientMessage(playerid,-1,"You're tutorial is finish.");
			SpawnPlayer(playerid);
            return 1;
        }
    }
    return 1;
}
how do I make my character spawn right after the tutorial is finished and give him some cash (AND save it)? spawnplayer doesn't work for me..and when i use GivePlayerMoney is just doesn't save it when I login next time.

How to fix that? p.s. for death too


thanks in advance to anyone who can help
Reply
#2

You have more options. You may set the Money from the moment where you create the INI file.

Quote:

new INI:file = INI_Open(UserPath(playerid));
INI_SetTag(file, "PlayerInfo");
INI_WriteString(file, "Password", PlayerInfo[playerid][Password]);
INI_WriteInt(file, "AdminLevel", 0);
INI_WriteInt(file, "VIPLevel", 0);
INI_WriteInt(file, "Money", 0);
INI_WriteInt(file, "Score", 0);
INI_WriteInt(file, "Kills", 0);
INI_WriteInt(file, "Deaths", 0);
INI_WriteInt(file, "Faction", 0);
INI_WriteInt(file, "Facrank", 0);
INI_WriteInt(file, "Facleader", 0);
INI_Close(file);

You need to keep in mind that if the player is going to take the tutorial again in some point, his money is going to be SET and not updated.

You may also set players money in right after your tutorial, as I read your code. In case X, the last case in general, you may use your function to set players money. You need to search for your give money function in your gamemode and use it in your last case.

If your functions doesn't work, you would like to paste the functions here so we can figure it out.
Reply
#3

Quote:
Originally Posted by TheDrx
Посмотреть сообщение
You have more options. You may set the Money from the moment where you create the INI file.



You need to keep in mind that if the player is going to take the tutorial again in some point, his money is going to be SET and not updated.

You may also set players money in right after your tutorial, as I read your code. In case X, the last case in general, you may use your function to set players money. You need to search for your give money function in your gamemode and use it in your last case.

If your functions doesn't work, you would like to paste the functions here so we can figure it out.
Aha, thank you, but even if I give him money right after he finishes the tutorial, the ini file states 0 and /stats check also gives me a 0 value.. +when I login next time, I spawn with the same way I spawned on the first time.

P.S. the spawnplayer on the last case, doesn't spawn the player, it just shows the <<<>>>>SPAWN buttons, and you have to hit the button, how do I cancel that?


basically what I am asking is:

how to save the money/pos?
how to spawn the player after he finishes the tutorial/or after he dies?


thanks!

p.s. I have this:
Код:
new INI:file = INI_Open(UserPath(playerid));
           	INI_SetTag(file, "PlayerInfo");
           	INI_WriteString(file, "Password", PlayerInfo[playerid][Password]);
           	INI_WriteInt(file, "AdminLevel", 0);
           	INI_WriteInt(file, "VIPLevel", 0);
           	INI_WriteInt(file, "Money", 0);
           	INI_WriteInt(file, "Score", 0);
           	INI_WriteInt(file, "Kills", 0);
           	INI_WriteInt(file, "Deaths", 0);
           	INI_WriteInt(file, "Faction", 0);
			INI_WriteInt(file, "Facrank", 0);
			INI_WriteInt(file, "Facleader", 0);
           	INI_Close(file);
when I edit the money here, it doesn't give the player money in game when I login..the data just doesn't save..

I am getting a YSI corrupted memory message *beep* when I start server.exe
server log:

Код:
SA-MP Dedicated Server
----------------------
v0.3.7-R2, ©2005-2015 SA-MP Team

[21:07:16] 
[21:07:16] Server Plugins
[21:07:16] --------------
[21:07:16]  Loading plugin: streamer
[21:07:16] 

*** Streamer Plugin v2.8.2 by Incognito loaded ***

[21:07:16]   Loaded.
[21:07:16]  Loading plugin: sscanf
[21:07:16] 

[21:07:16]  ===============================

[21:07:16]       sscanf plugin loaded.     

[21:07:16]          Version:  2.8.2        

[21:07:16]    © 2012 Alex "******" Cole  

[21:07:16]  ===============================

[21:07:16]   Loaded.
[21:07:16]  Loading plugin: whirlpool
[21:07:16]  
[21:07:16]  ==================
[21:07:16]  
[21:07:16]   Whirlpool loaded
[21:07:16]  
[21:07:16]  ==================
[21:07:16]  
[21:07:16]   Loaded.
[21:07:16]  Loaded 3 plugins.

[21:07:16] 
[21:07:16] Filterscripts
[21:07:16] ---------------
[21:07:16]   Loading filterscript 'gl_realtime.amx'...
[21:07:16]   Loading filterscript 'skinchanger.amx'...
[21:07:16] 
--Admin Player Skin Changer Loaded

[21:07:16]   Loading filterscript 'vspawner.amx'...
[21:07:16] 
--Admin Vehicle Spawner Loaded

[21:07:16]   Loaded 3 filterscripts.

[21:07:16]  
[21:07:16]  
[21:07:16]  
[21:07:16]  ======================================= 
[21:07:16]  |                                     | 
[21:07:16]  |        YSI version 4.00.0001        | 
[21:07:16]  |        By Alex "******" Cole        | 
[21:07:16]  |                                     | 
[21:07:16]  ======================================= 
[21:07:16]  
[21:07:16] *** YSI Warning: y_malloc set up via "CallLocalFunction", memory corruption is a remote possibility
[21:07:16] Number of vehicle models: 3
maybe it has something to do with it?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)