Loading a string with y_ini
#1

Ok i made this temp vip system which will give vip permission by months, example: Once the command is used by the admin it will count months so i can set you to vip for any amount of months anyways, i know ini cant save big intergers and i was on the samp forums and saw someone who had the same issue and a guy suggested that he save the time as and string instead of an integer and load it as a string.

I have some experiences in loading and saving strings because of my ban system i used and it all works but when i 'm trying to load the vip time as an string it doesn't work, instead i get some errors and warnings.

PHP код:
//Loading the string
    
INI_String("VIPTIME"pInfo[playerid][VIPTIME],20);//line 2977
//Vip command
CMD:vip(playerid,params[])
{
      if(
IsPlayerAdmin(playerid) || pInfo[playerid][Admin] >= 7)
    {
          new 
id,months;
        if(
sscanf(params,"ud",id,months)) return SendClientMessage(playerid,COLOR_RED,"Usage: /setvip [playerid] [months]");
        if(
months>12) return SendClientMessage(playerid,COLOR_RED,"Months can not be greater than 12");
        if(
months<1) return SendClientMessage(playerid,COLOR_RED,"Months can not be 0 or less than 0");
        if(
id==INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_RED,"That player is not online");
        if(
pInfo[id][VIP]==1) return SendClientMessage(playerid,COLOR_RED,"This player is already VIP!");
        new 
str[128];
        
format(str,sizeof(str),"You have recieved VIP for %d months.",months);
        
SendClientMessage(id,COLOR_RED,str);
        
format(str,sizeof(str),"Enjoy ~g~%d Month VIP!",months);
        
GameTextForPlayer(id,str,3000,5);
        
SendClientMessage(id,COLOR_RED,"Type /vcmds for the list of VIP commands.");
        
format(str,sizeof(str),"You have given %s a VIP package for %d months subscription.",GetName(id),months);
        
SendClientMessage(playerid,COLOR_RED,str);
//this is the part in question
        
new vtime gettime()+60*60*24*30*months;
         new 
INI:File INI_Open(UserPath(id));
        
INI_SetTag(File,"data");
         
INI_WriteString(File,"VIPTIME",vtime);
            
INI_WriteInt(File,"VIP"1);
        
INI_Close(File);
    }
    else return 
ShowMessage(playeriderror1);
    return 
1;

errors
Код:
./comps/callbacks.pwn(2977) : error 001: expected token: ")", but found "["
./comps/callbacks.pwn(2977) : warning 215: expression has no effect
./comps/callbacks.pwn(2977) : error 001: expected token: ";", but found "]"
./comps/callbacks.pwn(2977) : error 029: invalid expression, assumed zero
./comps/callbacks.pwn(2977) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.
Reply
#2

VIPTIME in enumerator is integer and not a string; thus the error. The solution is simple - update to latest version of YSI 4 and use INI_WriteInt function.

valstr crashes on high numbers but it has been fixed: https://github.com/Misiur/YSI-Includ...iting.inc#L333
Reply
#3

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
valstr crashes on high numbers but it has been fixed: https://github.com/Misiur/YSI-Includ...iting.inc#L333
Ok so i downloaded the ysi4 but what should i do with the information on the link you provided, should i add it to a file or something? and if yes what file should i add it too.

Update :
Код:
C:\Users\Andre'\Desktop\Andre'\samp\pawno\include\YSI\..\YSI_Storage\..\YSI_Internal\..\amx\codescan.inc(72) : fatal error 100: cannot read from file: "addressof"

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

Nothing, I just linked you so you can see that it uses format instead of valstr to avoid the crash. It seems like it cannot read correctly so:

Re-download ysi 4 (https://github.com/Misiur/YSI-Includ...ive/YSI.tl.zip) and amx_assembly (https://github.com/Zeex/amx_assembly/archive/master.zip).
Extract them and create a folder called amx in YSI-Includes-YSI.tl folder.
Cut and paste all files from amx_assembly-master folder into amx folder you just created.
Last, cut and paste all files and folders from YSI-Includes-YSI.tl into pawno/include folder.

This allows you to just use:
pawn Код:
#include <YSI\y_ini>
Reply
#5

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Nothing, I just linked you so you can see that it uses format instead of valstr to avoid the crash. It seems like it cannot read correctly so:

Re-download ysi 4 (https://github.com/Misiur/YSI-Includ...ive/YSI.tl.zip) and amx_assembly (https://github.com/Zeex/amx_assembly/archive/master.zip).
Extract them and create a folder called amx in YSI-Includes-YSI.tl folder.
Cut and paste all files from amx_assembly-master folder into amx folder you just created.
Last, cut and paste all files and folders from YSI-Includes-YSI.tl into pawno/include folder.

This allows you to just use:
pawn Код:
#include <YSI\y_ini>
Ok mate i've done all that you said to do but it gives me a list of warnings now

Код:
C:\Users\Andre'\Desktop\Andre'\samp\pawno\include\YSI\..\YSI_Storage\..\YSI_Core\y_utils.inc(430) : warning 201: redefinition of constant/macro (symbol "isnull(%1)")
C:\Users\Andre'\Desktop\Andre'\samp\pawno\include\OPSP.inc(180) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
C:\Users\Andre'\Desktop\Andre'\samp\pawno\include\OPSP.inc(279) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(460) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(782) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(1075) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2192) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2200) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2210) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2241) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2300) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2314) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2323) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2332) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2341) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2351) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2754) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/functions.pwn(2881) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(168) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(643) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(2299) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(2636) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(2705) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(2843) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(2865) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(3144) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(3280) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/callbacks.pwn(3466) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(1202) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(1211) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(3339) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(3359) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(3377) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(4099) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(4586) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(5245) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(5308) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(5453) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(5581) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6189) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6204) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6225) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6244) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6258) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6276) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6308) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6325) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6361) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6399) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6419) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6441) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6457) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6477) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6495) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6517) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6536) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6554) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6568) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(6935) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(7230) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(7489) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(7514) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(7604) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(7635) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(7785) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(7850) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(8054) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(8075) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
./comps/cmds.pwn(8493) : warning 219: local variable "using_deprecated_foreach_syntax" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:          18216 bytes
Code size:          1363816 bytes
Data size:         57003504 bytes
Stack/heap size:   17039360 bytes; estimated max. usage: unknown, due to recursion
Total requirements:75424896 bytes

69 Warnings.
Reply
#6

isnull is already defined in YSI so don't re-define it in your script. There might be an include that re-defines it though so if there is, you can remove that line.

As for the warning, ****** did very well on warning the users not to use the deprecated syntax. You need to change old to new syntax:
pawn Код:
// old and deprecated syntax
foreach(Player, i)
pawn Код:
// new and correct syntax
foreach(new i : Player)
Reply
#7

Thanks mate rep+
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)