SA-MP Forums Archive
Dini problem - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Dini problem (/showthread.php?tid=268033)



Dini problem - Sreadon - 10.07.2011

Hi, I have another problem.. I've find an VIP script on this forum, and I've add to it savedata, it's work perfectly when I use a fonction who verify the dini VIP = 2 but no when I want to write in the player's ini.

But, If I do the command, /setvip 'myid' 2, it's work perfectly! In my stat, I've VIP=2, but if I try to make a friend VIP, with the same command, the VIP lign in the .ini of my friend stay to VIP=0. Here the code, I've tryed so many solutions, but I don't know where is my error, I think it's at the end, in the write part..

pawn Код:
CMD:setvip( playerid, params[ ] ) {
    if( !IsPlayerAdmin( playerid ) )
        return SendClientMessage( playerid, -1, "You need to be a RCON admin to use this. " ); // You need to be RCON to set someone's VIP
    new
        id,
        vip
    ;
    if( sscanf( params, "ud", id, vip ) )
        return SendClientMessage( playerid, -1, "USAGE: /setvip [ID] [1 for silver, 2 for gold, 0 if you want to remove VIP]. " );
    if( !IsPlayerConnected( id ) || id == INVALID_PLAYER_ID )
        return SendClientMessage( playerid, -1, "Invalid player ID (player not connected). " );
    if( vip > 2 || vip < 0 )
        return SendClientMessage( playerid, -1, "The VIP rank must be between 0 and 2. " );
    SetPVarInt( id, "VIP", vip );
    new
        str[ 128 ],
        pName[ 24 ],
        aName[ 24 ],
        vipstr[ 8 ]
    ;
    if( vip == 0 )
        vipstr = "none";
    if( vip == 1 )
        vipstr = "silver";
    if( vip == 2 )
        vipstr = "gold";
    GetPlayerName( id, pName, 24 );
    GetPlayerName( playerid, aName, 24 );
    format( str, sizeof str, "RCON administrator %s has set your donor rank to %s", aName, vipstr );
    SendClientMessage( id, -1, str );
    format( str, sizeof str, "You have set %s's donor rank to %s", pName, vipstr );
    //new name[MAX_PLAYER_NAME]; // I've add it
    GetPlayerName(playerid, pName, sizeof(pName)); // I've add it
    format(file, sizeof(file), "RicAdmin/users/%s.ini", pName); // I've add it
    dini_IntSet(file, "VIP",PlayerInfo[playerid][VIP] = 2); // I've add it
    return SendClientMessage( playerid, -1, str );
}
Thank's for your help, and sorry for my english.. I'm not english.


Re: Dini problem - Basicz - 10.07.2011

Try this :

pawn Код:
CMD:setvip( playerid, params[ ] ) {
    if( !IsPlayerAdmin( playerid ) )
        return SendClientMessage( playerid, -1, "You need to be a RCON admin to use this. " ); // You need to be RCON to set someone's VIP
    new
        id,
        vip
    ;
    if( sscanf( params, "ud", id, vip ) )
        return SendClientMessage( playerid, -1, "USAGE: /setvip [ID] [1 for silver, 2 for gold, 0 if you want to remove VIP]. " );
    if( !IsPlayerConnected( id ) || id == INVALID_PLAYER_ID )
        return SendClientMessage( playerid, -1, "Invalid player ID (player not connected). " );
    if( vip > 2 || vip < 0 )
        return SendClientMessage( playerid, -1, "The VIP rank must be between 0 and 2. " );
    SetPVarInt( id, "VIP", vip );
    new
        str[ 128 ],
        pName[ 24 ],
        aName[ 24 ],
        vipstr[ 8 ]
    ;
    if( vip == 0 )
        vipstr = "none";
    if( vip == 1 )
        vipstr = "silver";
    if( vip == 2 )
        vipstr = "gold";
    GetPlayerName( id, pName, 24 );
    GetPlayerName( playerid, aName, 24 );
    format( str, sizeof str, "RCON administrator %s has set your donor rank to %s", aName, vipstr );
    SendClientMessage( id, -1, str );
    format( str, sizeof str, "You have set %s's donor rank to %s", pName, vipstr );
    //new name[MAX_PLAYER_NAME]; // I've add it
    GetPlayerName(playerid, pName, sizeof(pName)); // I've add it
    format(file, sizeof(file), "RicAdmin/users/%s.ini", pName); // I've add it
    // Added a Debug
    if ( fexist( file ) ) {
        print( "It works!" ); // See your samp-server.exe, and it should print "It works!"
        dini_IntSet(file, "VIP", vip); // I've changed it
    }
    return SendClientMessage( playerid, -1, str );
}



Re : Dini problem - Sreadon - 10.07.2011

That "said" It works! but nothing save... I've seen something in the samp-server.exe:

sscanf warning "Format specifer does not match parameter count"

But, thank's, and if you have an other idea..^^ thank's.

[EDIT]: I've solved the "sscanf warning "Format specifer does not match parameter count"" Just need to change "ud" by "id"


Re : Dini problem - Sreadon - 11.07.2011

Sorry for the "up" of the topic, but I can't solve this problem.. I search but don't find it.


Re: Dini problem - Roko_foko - 11.07.2011

Try to redownload dini include, have you maybe changed something in it?


Re : Dini problem - Sreadon - 11.07.2011

I'll try it, and no, I've changed nothing in the includes...

[EDIT]: Nop, that change nothing. (Download and replace the old dini).


Re: Dini problem - Roko_foko - 11.07.2011

hmm you could try to find where problem comes by adding printf("test1"),printf("test2"),... in your include(the one in "pawno" folder ), you can "open with" it with pawno and act like it's normal pawno script. And don't forget to make copy of include before you start to change it. I can't see the problem in your script.


Re: Dini problem - Wesley221 - 11.07.2011

Double check your folders
pawn Код:
format(file, sizeof(file), "RicAdmin/users/%s.ini", pName);
Youre sure you got the folders RicAdmin/users?

Edit: duh, didnt saw your post - Ignore me


Re: Dini problem - Shadoww5 - 11.07.2011

Quote:
Originally Posted by Sreadon
Посмотреть сообщение
Hi, I have another problem.. I've find an VIP script on this forum, and I've add to it savedata, it's work perfectly when I use a fonction who verify the dini VIP = 2 but no when I want to write in the player's ini.

But, If I do the command, /setvip 'myid' 2, it's work perfectly! In my stat, I've VIP=2, but if I try to make a friend VIP, with the same command, the VIP lign in the .ini of my friend stay to VIP=0. Here the code, I've tryed so many solutions, but I don't know where is my error, I think it's at the end, in the write part..

pawn Код:
CMD:setvip( playerid, params[ ] ) {
    if( !IsPlayerAdmin( playerid ) )
        return SendClientMessage( playerid, -1, "You need to be a RCON admin to use this. " ); // You need to be RCON to set someone's VIP
    new
        id,
        vip
    ;
    if( sscanf( params, "ud", id, vip ) )
        return SendClientMessage( playerid, -1, "USAGE: /setvip [ID] [1 for silver, 2 for gold, 0 if you want to remove VIP]. " );
    if( !IsPlayerConnected( id ) || id == INVALID_PLAYER_ID )
        return SendClientMessage( playerid, -1, "Invalid player ID (player not connected). " );
    if( vip > 2 || vip < 0 )
        return SendClientMessage( playerid, -1, "The VIP rank must be between 0 and 2. " );
    SetPVarInt( id, "VIP", vip );
    new
        str[ 128 ],
        pName[ 24 ],
        aName[ 24 ],
        vipstr[ 8 ]
    ;
    if( vip == 0 )
        vipstr = "none";
    if( vip == 1 )
        vipstr = "silver";
    if( vip == 2 )
        vipstr = "gold";
    GetPlayerName( id, pName, 24 );
    GetPlayerName( playerid, aName, 24 );
    format( str, sizeof str, "RCON administrator %s has set your donor rank to %s", aName, vipstr );
    SendClientMessage( id, -1, str );
    format( str, sizeof str, "You have set %s's donor rank to %s", pName, vipstr );
    //new name[MAX_PLAYER_NAME]; // I've add it
    GetPlayerName(playerid, pName, sizeof(pName)); // I've add it
    format(file, sizeof(file), "RicAdmin/users/%s.ini", pName); // I've add it
    dini_IntSet(file, "VIP",PlayerInfo[playerid][VIP] = 2); // I've add it
    return SendClientMessage( playerid, -1, str );
}
Thank's for your help, and sorry for my english.. I'm not english.
Code fixed:

PHP код:
CMD:setvipplayeridparams[ ] ) 
{
    if( !
IsPlayerAdminplayerid ) ) return SendClientMessageplayerid, -1"You need to be a RCON admin to use this. " ); 
    new 
idvip;
    if( 
sscanfparams"ud"idvip ) ) return SendClientMessageplayerid, -1"USAGE: /setvip [ID] [1 for silver, 2 for gold, 0 if you want to remove VIP]." );
    if( !
IsPlayerConnectedid ) || id == INVALID_PLAYER_ID ) return SendClientMessageplayerid, -1"Invalid player ID (player not connected). " );
    if(
vip 2) return SendClientMessageplayerid, -1"The VIP rank must be between 0 and 2. " );
    
SetPVarIntid"VIP"vip );
    new 
str128 ], pName24 ], aName24 ], vipstr];
    if( 
vip == ) { vipstr "none"; }
        if( 
vip == ) { vipstr "silver"; }
    if( 
vip == ) { vipstr "gold"; }
    
GetPlayerNameidpName24 );
    
GetPlayerNameplayeridaName24 );
    
formatstrsizeof str"RCON administrator %s has set your donor rank to %s."aNamevipstr );
    
SendClientMessageid, -1str );
    
formatstrsizeof str"You have set %s's donor rank to %s."pNamevipstr );
    
SendClientMessageplayerid, -1str );
    
formatstrsizeof(str), "/RicAdmin/users/%s.ini"pName);
    
PlayerInfo[id][VIP] = vip;
    if(!
fexist(str)) { dini_Create(str); }
    
dini_IntSet(str"VIP"PlayerInfo[id][VIP]);
    return 
1;




Re : Dini problem - Sreadon - 11.07.2011

Really thank's man that works, and thank's too to the others who have tried to help me