Save Player Color
#1

if player choose color and leave the server, after he/she join back the color he choose before still the same. How??

PHP код:
#include <a_samp>
#define GREEN 0x33AA33AA
#define RED 0xAA3333AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define BLUE 0x0000BBAA
#define GOLD 0xB8860BAA
#define PINK 0xFFC0CBAA
#define PURPLE 0x800080FF
#if defined FILTERSCRIPT
public OnFilterScriptInit()
{
    print(
"\n--------------------------------------");
    print(
"Player Color");
    print(
"--------------------------------------\n");
    return 
1;
}
public 
OnFilterScriptExit()
{
    return 
1;
}
#else
#endif
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/color"cmdtexttrue10) == 0)
    {
        
ShowPlayerDialog(playerid5DIALOG_STYLE_LIST"Player Color""White\nGreen\nRed\nYellow\nBlue\nPurple\nGold\nPink""Choose""Close");
        return 
1;
    }
    return 
0;
}
public 
OnDialogResponse(playeriddialogidresponselistiteminputtext[])
{
    if(
dialogid == 5)
    {
          if(
response)
          {
              new 
string[128];
            new 
message[256+1];
            if(
listitem == 0)
            {
            
format(stringsizeof(string), "You got now a WHITE name");
              
SendClientMessage(playerid0xFFFFFFAAmessage);
              
SetPlayerColor(playeridWHITE);
             }
            if(
listitem == 1)
            {
              
format(stringsizeof(string), "You got now a GREEN name");
              
SendClientMessage(playerid0x33AA33AAmessage);
              
SetPlayerColor(playeridGREEN);
               return 
1;
              }
            if(
listitem == 2)
            {
              
format(stringsizeof(string), "You got now a RED name");
              
SendClientMessage(playerid0xAA3333AAmessage);
              
SetPlayerColor(playeridRED);
               return 
1;
              }
            if(
listitem == 3)
            {
              
format(stringsizeof(string), "You got now a YELLOW name");
              
SendClientMessage(playerid0xFFFF00AAmessage);
              
SetPlayerColor(playeridYELLOW);
               return 
1;
              }
            if(
listitem == 4)
            {
              
format(stringsizeof(string), "You got now a BLUE name");
              
SendClientMessage(playerid0x0000BBAAmessage);
              
SetPlayerColor(playeridBLUE);
               return 
1;
              }
            if(
listitem == 5)
            {
              
format(stringsizeof(string), "You got now a PURPLE name");
              
SendClientMessage(playerid0x800080FFmessage);
              
SetPlayerColor(playeridPURPLE);
               return 
1;
              }
            if(
listitem == 6)
            {
              
format(stringsizeof(string), "You got now a GOLD name");
              
SendClientMessage(playerid0xB8860BAAmessage);
              
SetPlayerColor(playeridGOLD);
               return 
1;
              }
            if(
listitem == 7)
            {
              
format(stringsizeof(string), "You got now a PINK name");
              
SendClientMessage(playerid0xFFC0CBAAmessage);
              
SetPlayerColor(playeridPINK);
               return 
1;
              }
          }
    }
    return 
1;

Reply
#2

First, do you have a file saving system?

Also; LOL at your signature, fail.
Reply
#3

Quote:
Originally Posted by iGetty
Посмотреть сообщение
First, do you have a file saving system?

Also; LOL at your signature, fail.
im using Luxadmin.

it includes the following..
#include <ldudb>
#include <lfuncs>

i think its too much complicated if i add the save file script for player color in luxadmin. Can you help me with that?

EDIT: My signature looks attractive
Reply
#4

kbalor try this

Код:
/*
Colour Save
*/

#include <a_samp>
#include <dini>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Colour Save!");
    print("--------------------------------------\n");
    return 1;
}

#endif


public OnPlayerCommandText(playerid, cmdtext[])
{
    new file[256],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ini", name);

    if (strcmp("/cc 1", cmdtext, true, 10) == 0)
    {
        SetPlayerColor(playerid, 0xff0000ff);
        SendClientMessage(playerid, 0xff0000ff, "%s has changed the colour");
        return 1;
    }
	if (strcmp("/color save", cmdtext, true) == 0)
    {
        if(dini_Int(file,"alreadysaved") != 0) return SendClientMessage(playerid,0xff0000ff,"Sorry , but you already saved your color once!");
        if(!dini_Int(file,"alreadysaved"))
        {
             dini_IntSet(file,"savedcolour",GetPlayerColor(playerid));
             dini_IntSet(file,"alreadysaved",1);
        }
        return 1;
    }
    return 0;
}
Reply
#5

Quote:
Originally Posted by God'Z War
Посмотреть сообщение
kbalor try this

Код:
/*
Colour Save
*/

#include <a_samp>
#include <dini>

#if defined FILTERSCRIPT

public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print(" Colour Save!");
    print("--------------------------------------\n");
    return 1;
}

#endif


public OnPlayerCommandText(playerid, cmdtext[])
{
    new file[256],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ini", name);

    if (strcmp("/cc 1", cmdtext, true, 10) == 0)
    {
        SetPlayerColor(playerid, 0xff0000ff);
        SendClientMessage(playerid, 0xff0000ff, "%s has changed the colour");
        return 1;
    }
	if (strcmp("/color save", cmdtext, true) == 0)
    {
        if(dini_Int(file,"alreadysaved") != 0) return SendClientMessage(playerid,0xff0000ff,"Sorry , but you already saved your color once!");
        if(!dini_Int(file,"alreadysaved"))
        {
             dini_IntSet(file,"savedcolour",GetPlayerColor(playerid));
             dini_IntSet(file,"alreadysaved",1);
        }
        return 1;
    }
    return 0;
}
sorry but nothing happens. im gonna sleep now. hopefully after i wake up. there is a solution already thanks
Reply
#6

i included with your cmd
Код:
#include <a_samp>
#include <dini>
#define GREEN 0x33AA33AA
#define RED 0xAA3333AA
#define YELLOW 0xFFFF00AA
#define WHITE 0xFFFFFFAA
#define BLUE 0x0000BBAA
#define GOLD 0xB8860BAA
#define PINK 0xFFC0CBAA
#define PURPLE 0x800080FF

#if defined FILTERSCRIPT



public OnFilterScriptInit()
{
    print("\n--------------------------------------");
    print("Player Color");
    print("--------------------------------------\n");
    return 1;
}

public OnFilterScriptExit()
{
    return 1;
}

#else


#endif



public OnPlayerCommandText(playerid, cmdtext[])
{
    new file[256],name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
	format(file, sizeof(file), "%s.ini", name);
    if (strcmp("/color", cmdtext, true, 10) == 0)
    {
        ShowPlayerDialog(playerid, 5, DIALOG_STYLE_LIST, "Player Color", "White\nGreen\nRed\nYellow\nBlue\nPurple\nGold\nPink", "Choose", "Close");
        return 1;
    }
	if (strcmp("/color save", cmdtext, true) == 0)
    {
        if(dini_Int(file,"alreadysaved") != 0) return SendClientMessage(playerid,0xff0000ff,"Sorry , but you already saved your color once!");
        if(!dini_Int(file,"alreadysaved"))
        {
             dini_IntSet(file,"savedcolour",GetPlayerColor(playerid));
             dini_IntSet(file,"alreadysaved",1);
        }
        return 1;
    }
    return 0;
}
public OnDialogResponse(playerid, dialogid, response, listitem, inputtext[])
{
    if(dialogid == 5)
    {
          if(response)
          {
          	new string[128];
            new message[256+1];
            if(listitem == 0)
            {
            format(string, sizeof(string), "You got now a WHITE name");
            SendClientMessage(playerid, 0xFFFFFFAA, message);
            SetPlayerColor(playerid, WHITE);
             }
            if(listitem == 1)
            {
              format(string, sizeof(string), "You got now a GREEN name");
              SendClientMessage(playerid, 0x33AA33AA, message);
              SetPlayerColor(playerid, GREEN);
              return 1;
              }
            if(listitem == 2)
            {
              format(string, sizeof(string), "You got now a RED name");
              SendClientMessage(playerid, 0xAA3333AA, message);
              SetPlayerColor(playerid, RED);
              return 1;
              }
            if(listitem == 3)
            {
              format(string, sizeof(string), "You got now a YELLOW name");
              SendClientMessage(playerid, 0xFFFF00AA, message);
              SetPlayerColor(playerid, YELLOW);
              return 1;
              }
            if(listitem == 4)
            {
              format(string, sizeof(string), "You got now a BLUE name");
              SendClientMessage(playerid, 0x0000BBAA, message);
              SetPlayerColor(playerid, BLUE);
              return 1;
              }
            if(listitem == 5)
            {
              format(string, sizeof(string), "You got now a PURPLE name");
              SendClientMessage(playerid, 0x800080FF, message);
              SetPlayerColor(playerid, PURPLE);
              return 1;
              }
            if(listitem == 6)
            {
              format(string, sizeof(string), "You got now a GOLD name");
              SendClientMessage(playerid, 0xB8860BAA, message);
              SetPlayerColor(playerid, GOLD);
              return 1;
              }
            if(listitem == 7)
            {
              format(string, sizeof(string), "You got now a PINK name");
              SendClientMessage(playerid, 0xFFC0CBAA, message);
              SetPlayerColor(playerid, PINK);
              return 1;
              }
          }
    }
    return 1;
}
Reply
#7

Man its not working but no error. Can you make a auto save/load to make it easy?? or anyone here viewing this thread?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)