Save Player Colour
#1

Hey Scripters!!!

Help me in saving player's colour.

I want like when player type /colourred

It changed to red color.

And when player type /Savecolor

It saves color player. and when player connect and disconnect but i want save.

And when player type /savecolor again it not saves anymore.

Thanks for ur help.
Reply
#2

under public OnPlayerCommandText
Код:
new file[256];
GetPlayerName(playerid, name, sizeof(name));
format(file, sizeof(file), %s.ini, name);

if(strcmp(cmdtext,"/colourred",true) == 0)
{
SetPlayerColor(playerid,0xff0000ff);
return 1'
}

if(strcmp(cmdtext,"/savecolour",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;
}
Reply
#3

pawn Код:
/*
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];
    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, 10) == 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;
}
Help.

pawn Код:
error 017: undefined symbol "name"
error 017: undefined symbol "name"
error 029: invalid expression, assumed zero
fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
Reply
#4

pawn Код:
new name[MAX_PLAYER_NAME];
Reply
#5

sorry my bad
instad of just new file[256];
make it new file[256],name[MAX_PLAYER_NAME];
Reply
#6

pawn Код:
/*
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, 10) == 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;
}
pawn Код:
(25) : error 029: invalid expression, assumed zero
(25) : error 017: undefined symbol "s"
(25) : error 029: invalid expression, assumed zero
(25) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


4 Errors.
stilll
Reply
#7

You are missing the quotes for this format function, it should be:

pawn Код:
format(file, sizeof(file), "%s.ini", name);
Reply
#8

My mistake, was thinking of something else.
Reply
#9

Quote:
Originally Posted by Stigg
Посмотреть сообщение
Aswell, i dont think you can have spaces "/cc 1" in your commands.
Why not?

Although now that you brought my attention to that part of the code, why are people constantly using a length of 10 in their strcmp check for the command text comparison? It's like an obsession, but it's completely useless in all of these cases. Why do they even specify a length?

pawn Код:
if (strcmp("/color save", cmdtext, true) == 0)
That does the exact same thing, without the hassle of having to count up the length and insert it. The only reason you should be specifying a length is if you want to see if just part of the strings match.
Reply
#10

thx u both
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)