SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 20/01/2015, 09:18 PM   #1
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,679
Reputation: 362
Default Class resets to Cop?

solved

Last edited by vassilis; 27/01/2015 at 04:06 AM.
vassilis is offline   Reply With Quote
Old 20/01/2015, 09:26 PM   #2
nezo2001
Gangsta
 
Join Date: Nov 2014
Location: Cairo, Egypt
Posts: 680
Reputation: 26
Default Re: Class resets to Cop?

I don't know working with mysql but in y_ini you make this

When the player choose the skin do
PHP Code:
pinfo[playerid][skin] = //skinid ; 
PHP Code:
OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid)); //We open the file "I don't know in mysql"
        
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid)); //write in the file "In the database" in the skin colmun the last skin that the player was in it
       
INI_Close(File);
       return 
1;

PHP Code:
OnPlayerSpawn(playerid)
{
SetPlayerSkin(playeridpinfo[playerid][skin];
return 
1;

__________________
Quote:
Originally Posted by Human
When im met u, u were nub at scripting xD.

But now, i'm impressed. Good job.
Don't look at my history. Everyone started somewhere
nezo2001 is offline   Reply With Quote
Old 20/01/2015, 09:32 PM   #3
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,679
Reputation: 362
Default Re: Class resets to Cop?

Quote:
Originally Posted by nezo2001 View Post
I don't know working with mysql but in y_ini you make this

When the player choose the skin do
PHP Code:
pinfo[playerid][skin] = //skinid ; 
PHP Code:
OnPlayerDisconnect(playeridreason)
{
    new 
INI:File INI_Open(UserPath(playerid)); //We open the file "I don't know in mysql"
        
INI_WriteInt(File,"Skin",GetPlayerSkin(playerid)); //write in the file "In the database" in the skin colmun the last skin that the player was in it
       
INI_Close(File);
       return 
1;

PHP Code:
OnPlayerSpawn(playerid)
{
SetPlayerSkin(playeridpinfo[playerid][skin];
return 
1;

You don't really help iask with MySQL since i use mysql but thanks..
vassilis is offline   Reply With Quote
Old 20/01/2015, 09:35 PM   #4
nezo2001
Gangsta
 
Join Date: Nov 2014
Location: Cairo, Egypt
Posts: 680
Reputation: 26
Default Re: Class resets to Cop?

All the problem to save and load and i think you can convert from y_ini to mysql
__________________
Quote:
Originally Posted by Human
When im met u, u were nub at scripting xD.

But now, i'm impressed. Good job.
Don't look at my history. Everyone started somewhere
nezo2001 is offline   Reply With Quote
Old 20/01/2015, 09:49 PM   #5
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,679
Reputation: 362
Default Re: Class resets to Cop?

I need someone with MySQL Knowledge to help me :/
vassilis is offline   Reply With Quote
Old 21/01/2015, 08:52 PM   #6
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,679
Reputation: 362
Default Re: Class resets to Cop?

still unsolved lol
vassilis is offline   Reply With Quote
Old 21/01/2015, 09:16 PM   #7
Ironboy
High-roller
 
Ironboy's Avatar
 
Join Date: Nov 2010
Location: Isle of Man
Posts: 1,942
Reputation: 433
Default Re: Class resets to Cop?

Give it a try
pawn Code:
case dialog_login:
    {
            if( response )
            {
                new pPass[ 20 ];
                if( sscanf( inputtext, "s[20]", pPass ) )
                {
                    SendClientMessage(playerid,-1,""COL_RED"CCNR SYSTEM"COL_WHITE": Our system requires to "COL_GREEN"login"COL_WHITE"to continue.");
                    Kick(playerid);
                    return 1;
                }
                OnPlayerLogin2( playerid, pPass );
                if(recentlyregistered[playerid] != 1)
                {
                    mysql_format(MySQLTunnel, Query, sizeof(Query), "SELECT `pskin`, `pteam` FROM `accounts` WHERE `pid` = '%d'", pinfo[playerid][pMySQLID]);
                    new Cache:result = mysql_query(MySQLTunnel, Query);
                    if(cache_get_row_count() != 0)
                    {
                        pinfo[playerid][Skin] = cache_get_field_content_int(0, "pskin");
                        pinfo[playerid][Team] = cache_get_field_content_int( 0, "pteam");
                        SetPlayerSkin(playerid,pinfo[playerid][Skin]);
                    }
                    cache_delete(result);
                    SetSpawnInfo(playerid, pinfo[playerid][Team], pinfo[playerid][Skin], 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                }

            }
            return 1;
   }
__________________
Ironboy is offline   Reply With Quote
Old 21/01/2015, 10:39 PM   #8
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,679
Reputation: 362
Default Re: Class resets to Cop?

Quote:
Originally Posted by Ironboy View Post
Give it a try
pawn Code:
case dialog_login:
    {
            if( response )
            {
                new pPass[ 20 ];
                if( sscanf( inputtext, "s[20]", pPass ) )
                {
                    SendClientMessage(playerid,-1,""COL_RED"CCNR SYSTEM"COL_WHITE": Our system requires to "COL_GREEN"login"COL_WHITE"to continue.");
                    Kick(playerid);
                    return 1;
                }
                OnPlayerLogin2( playerid, pPass );
                if(recentlyregistered[playerid] != 1)
                {
                    mysql_format(MySQLTunnel, Query, sizeof(Query), "SELECT `pskin`, `pteam` FROM `accounts` WHERE `pid` = '%d'", pinfo[playerid][pMySQLID]);
                    new Cache:result = mysql_query(MySQLTunnel, Query);
                    if(cache_get_row_count() != 0)
                    {
                        pinfo[playerid][Skin] = cache_get_field_content_int(0, "pskin");
                        pinfo[playerid][Team] = cache_get_field_content_int( 0, "pteam");
                        SetPlayerSkin(playerid,pinfo[playerid][Skin]);
                    }
                    cache_delete(result);
                    SetSpawnInfo(playerid, pinfo[playerid][Team], pinfo[playerid][Skin], 1958.3783, 1343.1572, 15.3746, 269.1425, 0, 0, 0, 0, 0, 0);
                    SpawnPlayer(playerid);
                }

            }
            return 1;
   }
Ok so i tried yours and i added the and printedf to check whats the problem i noticed that on print it says the correct skin and team (SKIN 292 TEAM 5(TEAM CIVILIAN) ) BUT i get spawned as cop...
vassilis is offline   Reply With Quote
Old 22/01/2015, 12:04 PM   #9
Ironboy
High-roller
 
Ironboy's Avatar
 
Join Date: Nov 2010
Location: Isle of Man
Posts: 1,942
Reputation: 433
Default Re: Class resets to Cop?

I guess recentlyregistered[playerid] turn to 1 once if someone register and i think you should place the team spawn inside of

pawn Code:
if(recentlyregistered[playerid] == 1)
{
//here along with the sql update
}
Quote:
Originally Posted by vassilis View Post
NOTE : I am creating the accounts table when gamemodeinit opens(just for once of course) could this affect in a way the saving? Should i make the table of accounts manually?
Creating table when the gamemode starts doesn't cause any problems but manual creation recommended.
__________________
Ironboy is offline   Reply With Quote
Old 22/01/2015, 07:27 PM   #10
vassilis
High-roller
 
vassilis's Avatar
 
Join Date: Nov 2009
Location: Greece,Athens
Posts: 1,679
Reputation: 362
Default Re: Class resets to Cop?

Quote:
Originally Posted by Ironboy View Post
I guess recentlyregistered[playerid] turn to 1 once if someone register and i think you should place the team spawn inside of

pawn Code:
if(recentlyregistered[playerid] == 1)
{
//here along with the sql update
}


Creating table when the gamemode starts doesn't cause any problems but manual creation recommended.
I noticed that when player registers it doesnt gives him the defualt money integer i have put($3000) but when he relogs so i guess its a problem with loading?
vassilis is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL connection ID resets [FMJ]PowerSurge Scripting Help 1 23/01/2014 06:38 PM
Everything resets FusionzzRoleplay Server Support 6 29/01/2013 06:37 PM
Dini resets Onyx Scripting Help 11 11/04/2012 03:02 PM
[HELP]Resets itself CleodeR_ Help Archive 1 16/03/2011 09:35 PM


All times are GMT. The time now is 07:40 AM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.