Error's
#1

help i get

error error 017: undefined symbol "file"

pawn Code:
public OnPlayerSpawn(playerid)
{
if(!dini_Exists(file))
{
SetPlayerPos(playerid,1647.1093,-2308.5242,14.5156);
}
else
{
SetPlayerPos(playerid, positionx,positiony,positionz);
SetPlayerSkin(playerid,skin);
}
return 1;
}
i have this line
pawn Code:
format(file, sizeof(file), "Players/%s.ini", pName);
please help
Reply
#2

pawn Code:
public OnPlayerSpawn(playerid)
{
    new pName[MAX_PLAYER_NAME];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(file, sizeof(file), "Players/%s.ini", pName);
    if(!dini_Exists(file))
        SetPlayerPos(playerid,1647.1093,-2308.5242,14.5156);
    else
    {
        SetPlayerPos(playerid, positionx,positiony,positionz);
        SetPlayerSkin(playerid,skin);
    }
    return 1;
}
Reply
#3

have done that but it does not make a file
Reply
#4

To make a file, use dini_Create
Reply
#5

my whole code is
pawn Code:
public OnPlayerConnect(playerid)
{
new pName[MAX_PLAYER_NAME], file[64];
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "Players/%s.ini", pName);
if(!dini_Exists(file)) gTeam[playerid] = TEAM_CIV;
else gTeam[playerid] = dini_Int(file, "Teams");
wanted = dini_Int(file, "Wanted");
positionx = dini_Int(file, "PositionX");
positiony = dini_Int(file, "PositionY");
positionz = dini_Int(file, "PositionZ");
skin = dini_Int(file, "skin");

public OnPlayerDisconnect(playerid, reason)
{
new Float:x;
new Float:y;
new Float:z;

GetPlayerPos(playerid,x,y,z);
skin = GetPlayerSkin(playerid);
positionx = x;
positiony = y;
positionz = z;

wanted = GetPlayerWantedLevel(playerid);
new pName[MAX_PLAYER_NAME], file[64];
GetPlayerName(playerid, pName, sizeof(pName));
format(file, sizeof(file), "Players/%s.ini", pName);
if(!dini_Exists(file)) dini_Create(file);
dini_IntSet(file, "Teams", gTeam[playerid]);
dini_IntSet(file, "Wanted",wanted);
dini_IntSet(file, "PositionX", floatround(positionx));
dini_IntSet(file, "PositionY", floatround(positiony));
dini_IntSet(file, "PositionZ", floatround(positionz));
dini_IntSet(file, "Skin", (skin));

return 1;
}

public OnPlayerSpawn(playerid)
{
if (!dini_Exists(file)) {
SetPlayerPos(playerid,1647.1093,-2308.5242,14.5156);
}
else
{
SetPlayerPos(playerid, positionx,positiony,positionz);
SetPlayerSkin(playerid,skin);
}
return 1;
}
i dont know if its right
Reply
#6

anyone?
Reply
#7

pawn Code:
public OnPlayerConnect(playerid)
{
    new pName[MAX_PLAYER_NAME], file[64];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file, sizeof(file), "Players/%s.ini", pName);
    if(!dini_Exists(file)) gTeam[playerid] = TEAM_CIV;
    else gTeam[playerid] = dini_Int(file, "Teams");
    wanted = dini_Int(file, "Wanted");
    positionx = dini_Int(file, "PositionX");
    positiony = dini_Int(file, "PositionY");
    positionz = dini_Int(file, "PositionZ");
    skin = dini_Int(file, "skin");
}

public OnPlayerDisconnect(playerid, reason)
{
    new Float:x;
    new Float:y;
    new Float:z;

    GetPlayerPos(playerid,x,y,z);
    skin = GetPlayerSkin(playerid);
    positionx = x;
    positiony = y;
    positionz = z;

    wanted = GetPlayerWantedLevel(playerid);
    new pName[MAX_PLAYER_NAME], file[64];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file, sizeof(file), "Players/%s.ini", pName);
    if(!dini_Exists(file)) dini_Create(file);
    dini_IntSet(file, "Teams", gTeam[playerid]);
    dini_IntSet(file, "Wanted",wanted);
    dini_IntSet(file, "PositionX", floatround(positionx));
    dini_IntSet(file, "PositionY", floatround(positiony));
    dini_IntSet(file, "PositionZ", floatround(positionz));
    dini_IntSet(file, "Skin", (skin));

    return 1;
}

public OnPlayerSpawn(playerid)
{
    new pName[MAX_PLAYER_NAME], file[64];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(file, sizeof(file), "Players/%s.ini", pName);
    if (!dini_Exists(file)) {
        dini_Create(file);//Create the file? <<<<<<<<<<<<<<<<<<<<<<<<<<
        SetPlayerPos(playerid,1647.1093,-2308.5242,14.5156);
    }
    else
    {
        SetPlayerPos(playerid, positionx,positiony,positionz);
        SetPlayerSkin(playerid,skin);
    }
    return 1;
}
Reply
#8

that didnt work
Reply
#9

Your code is missing lots of variables.
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
    new Float:x;
    new Float:y;
    new Float:z;

    GetPlayerPos(playerid,x,y,z);
    skin = GetPlayerSkin(playerid);
    //WHERE skin, positionx, positiony, positionz is defined!? Also for the rest of the code,
    positionx = x;
    positiony = y;
    positionz = z;
    // ...
}
Edit: And, what are you trying to do exactly and what the errors you are getting?
Reply
#10

i dont get any errors

the thing i want to do is to make a file which saves player's Team,Postion,Skin,Wanted level

EDIT:When i dont create (file) i get error that undefined symbol "file"
Reply
#11

Look the comments.

pawn Code:
public OnPlayerConnect(playerid)
{
    new
        pName[MAX_PLAYER_NAME],
        file[64];

    GetPlayerName(playerid, pName, sizeof(pName));
    format(file, sizeof(file), "Players/%s.ini", pName);
   
    if(!dini_Exists(file))
    {
        //if it doesn't exist it MUST be created.
        dini_Create(file);
       
        gTeam[playerid] = TEAM_CIV;
       
        new Float:x;
        new Float:y;
        new Float:z;

        GetPlayerPos(playerid,x,y,z);
        skin = GetPlayerSkin(playerid);
        positionx = x;
        positiony = y;
        positionz = z;
       
        dini_IntSet(file, "Teams", gTeam[playerid]);
        dini_IntSet(file, "Wanted",wanted);
       
       
        dini_IntSet(file, "PositionX", floatround(positionx));
        dini_IntSet(file, "PositionY", floatround(positiony));
        dini_IntSet(file, "PositionZ", floatround(positionz));
        //WHY floatround? It SHOULD be a FLOAT.
       
        dini_IntSet(file, "Skin", skin);
    }
    else
    {
        gTeam[playerid] = dini_Int(file, "Teams");
        wanted = dini_Int(file, "Wanted");
        positionx = dini_Int(file, "PositionX");
        positiony = dini_Int(file, "PositionY");
        positionz = dini_Int(file, "PositionZ");
        skin = dini_Int(file, "skin");
    }
   
    // wanted, positionx, positiony, positionz, skin MUST be an array like gTeam[playerid]!!!
}

public OnPlayerDisconnect(playerid, reason)
{
    new Float:x;
    new Float:y;
    new Float:z;

    GetPlayerPos(playerid,x,y,z);
    skin = GetPlayerSkin(playerid);
    positionx = x;
    positiony = y;
    positionz = z;

    wanted = GetPlayerWantedLevel(playerid);
    new pName[MAX_PLAYER_NAME], file[64];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file, sizeof(file), "Players/%s.ini", pName);
   
    if(!dini_Exists(file)){ dini_Create(file); }
   
   
    dini_IntSet(file, "Teams", gTeam[playerid]);
    dini_IntSet(file, "Wanted",wanted);
   
   
    dini_IntSet(file, "PositionX", floatround(positionx));
    dini_IntSet(file, "PositionY", floatround(positiony));
    dini_IntSet(file, "PositionZ", floatround(positionz));
    //WHY floatround? It SHOULD be a FLOAT.
   
    dini_IntSet(file, "Skin", skin);
   
    // wanted, positionx, positiony, positionz, skin MUST be an array like gTeam[playerid]!!!
    return 1;
}

public OnPlayerSpawn(playerid)
{
    new pName[MAX_PLAYER_NAME], file[64];
    GetPlayerName(playerid, pName, MAX_PLAYER_NAME);
    format(file, sizeof(file), "Players/%s.ini", pName);
    if(!dini_Exists(file))
    {
        dini_Create(file);//Create the file
        SetPlayerPos(playerid,1647.1093,-2308.5242,14.5156);
    }
    else
    {
        SetPlayerPos(playerid, positionx,positiony,positionz);
        SetPlayerSkin(playerid, skin);
        // positionx, positiony, positionz, skin MUST be an array like gTeam[playerid]!!!
    }
    return 1;
}
Reply
#12

umm all things just go random my position is still 0 and my team is still 2 and my skin also doesnt change
Reply
#13

anyone?
Reply
#14

pawn Code:
public OnPlayerConnect(playerid)
{
    new pName[MAX_PLAYER_NAME], file[64];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file, sizeof(file), "Players/%s.ini", pName);
    if(!dini_Exists(file)) gTeam[playerid] = TEAM_CIV;
    else gTeam[playerid] = dini_Int(file, "Teams");
    wanted = dini_Int(file, "Wanted");
    positionx = dini_Float(file, "PositionX");
    positiony = dini_Float(file, "PositionY");
    positionz = dini_Float(file, "PositionZ");
    skin = dini_Int(file, "skin");
}

public OnPlayerDisconnect(playerid, reason)
{
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    new pName[MAX_PLAYER_NAME], file[64];
    GetPlayerName(playerid, pName, sizeof(pName));
    format(file, sizeof(file), "Players/%s.ini", pName);
    if(!dini_Exists(file)) dini_Create(file);
    dini_IntSet(file, "Teams", gTeam[playerid]);
    dini_IntSet(file, "Wanted", GetPlayerWantedLevel(playerid));
    dini_FloatSet(file, "PositionX", x);
    dini_FloatSet(file, "PositionY", y);
    dini_FloatSet(file, "PositionZ", z);
    dini_IntSet(file, "Skin", GetPlayerSkin(playerid));
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(positionx == 0.0 && positiony == 0.0)
    {
        SetPlayerPos(playerid, 1647.1093, -2308.5242, 14.5156);
    }
    else
    {
        SetPlayerPos(playerid, positionx, positiony, positionz);
        SetPlayerSkin(playerid, skin);
    }
    return 1;
}
and make the "positionx", "positiony", and "positionz" to the Float variable
Reply
#15

Help
Reply
#16

pawn Code:
enum pDataE
{
    pWanted,
    pSkin,
    Float:posX,
    Float:posY,
    Float:posZ
};

new pData[MAX_PLAYERS][pDataE]


public OnPlayerConnect(playerid)
{
    new file[64];
    format(file, sizeof(file), "Players/%s.ini", GetPlayerNameEx(playerid));
    if(!dini_Exists(file))
    {
        gTeam[playerid] = TEAM_CIV;
        pData[playerid][pWanted] = 0;
        pData[playerid][posX] = 0.0;
        pData[playerid][posY] = 0.0;
        pData[playerid][posZ] = 0.0;
        pData[playerid][pSkin] = -1;
    }
    else
    {
        gTeam[playerid] = dini_Int(file, "Teams");
        pData[playerid][pWanted] = dini_Int(file, "Wanted");
        pData[playerid][posX] = dini_Float(file, "PositionX");
        pData[playerid][posY] = dini_Float(file, "PositionY");
        pData[playerid][posZ] = dini_Float(file, "PositionZ");
        pData[playerid][pSkin] = dini_Int(file, "skin");
    }
}
public OnPlayerDisconnect(playerid, reason)
{
    GetPlayerPos(playerid, pData[playerid][posX], pData[playerid][posY], pData[playerid][posZ]);
    new file[64];
    format(file, sizeof(file), "Players/%s.ini", GetPlayerNameEx(playerid));
    if(!dini_Exists(file)) dini_Create(file);
    dini_IntSet(file, "Teams", gTeam[playerid]);
    dini_IntSet(file, "Wanted", GetPlayerWantedLevel(playerid));
    dini_FloatSet(file, "PositionX", pData[playerid][posX]);
    dini_FloatSet(file, "PositionY", pData[playerid][posY]);
    dini_FloatSet(file, "PositionZ", pData[playerid][posZ]);
    dini_IntSet(file, "Skin", GetPlayerSkin(playerid));
    return 1;
}

public OnPlayerSpawn(playerid)
{
    if(pData[playerid][pSkin] == -1)
    {
        SetPlayerPos(playerid, 1647.1093, -2308.5242, 14.5156);
    }
    else
    {
        SetPlayerSkin(playerid, pData[playerid][pSkin]);
        SetPlayerPos(playerid, pData[playerid][posX], pData[playerid][posY], pData[playerid][posZ]);
    }
    return 1;
}

stock GetPlayerNameEx(playerid)
{
    new playername[MAX_PLAYER_NAME];
    GetPlayerName(playerid, playername, sizeof(playername));
    return playername;
}
Reply
#17

oK wait some time i working for your saving system ok?
Reply
#18

done that its not creating file nvm for this problem
Reply
#19

try this in a new script and if work replace with your script
pawn Code:
//Credits to SAMP using this
#include <a_samp>
//Credits to Dracoblue for dini
#include <dini>

#define CIV 0
#define YOUR_TEA_NAME_2 1
//Add more for others team..

#define SAVE_SKIN true // true for saving skin, false for not

 new Float:x, Float:y, Float:z;
new Float:Angle;
new gTeam[MAX_PLAYERS];
new bool: SaveSkin[MAX_PLAYERS];

new skin;

#define PlayerFile "Players/%s.ini" // replace Account with name of your folder

///deleting the Loose identitation wra
#pragma tabsize 0

public OnPlayerConnect(playerid)
{
         new name[MAX_PLAYER_NAME], file[256];
         GetPlayerName(playerid,name,sizeof(name));
         format(file,sizeof(file),PlayerFile,name);
         
         GetPlayerPos(playerid, x, y, z);
         GetPlayerFacingAngle(playerid,Angle);
         
         
         if(!dini_Exists(file) )
         {
                //setting team to 0 (civil) if not exist file
                gTeam[playerid] = CIV;
                dini_Create(file);
                dini_Set(file,"Name",name);
                dini_FloatSet(file,"X",0);
                dini_FloatSet(file,"Y",0);
                dini_FloatSet(file,"Z",0);
                dini_FloatSet(file,"Z",0);
                dini_IntSet(file,"Team",0);
                if(SaveSkin[playerid] == SAVE_SKIN)
                {
                         dini_IntSet(file,"Skin",-1);
                }
                                              else if(Saveskin[playerid] == false) return 0;
         }
}

public OnPlayerDisconnect(playerid,reason)
{

                 new name[MAX_PLAYER_NAME], file[256];
         GetPlayerName(playerid,name,sizeof(name));
         format(file,sizeof(file),PlayerFile,name);

         GetPlayerPos(playerid, x, y, z);
         GetPlayerFacingAngle(playerid,Angle);
         
                skin = GetPlayerSkin(playerid);
               
                if(SaveSkin[playerid] == SAVE_SKIN)
                {
                         dini_IntSet(file,"Skin",skin);
                         dini_FloatSet(file,"X",x);
                         dini_FloatSet(file,"Y",y);
                         dini_FloatSet(file,"Z",z);
                         dini_FloatSet(file,"Angle",Angle);
                         dini_IntSet(file,"Team",gTeam[playerid]);
                }
                                                 else if(Saveskin[playerid] == false) return 0;
   return 1;
}

public OnPlayerSpawn(playerid)
{
             new name[MAX_PLAYER_NAME], file[256];
         GetPlayerName(playerid,name,sizeof(name));
         format(file,sizeof(file),PlayerFile,name);
         
                if(SaveSkin[playerid] == SAVE_SKIN)
                {
                        SetPlayerSkin(playerid,dini_Int(file,"Skin"));
                }
                                             else if(Saveskin[playerid] == false) return 0;
               if(dini_Exists(file) )
               {
                    gTeam[playerid] = dini_Int(file,"Team");
                    SetPlayerPos(playerid,dini_Float(file,"X"),dini_Float(file,"Y"),dini_Float(file,"Z"));
                    SetPlayerFacingAngle(playerid,dini_Float(file,"Angle"));
               }
   return 1;
}
Reply
#20

i managed to fix it

anyway thanks for help
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)