Insurance system
#1

i made this code:

pawn Код:
stock insurancedelete(vehicleid, playerid)
{
  new house[256];
  format(house, sizeof(house), "%s.ini",VehicleInfo[vehicleid][vOwner]);
  printf("%s.ini", VehicleInfo[vehicleid][vOwner]);
  if(dini_Exists(house))
  {
                 insurance1[playerid] = dini_Int(house, "TrunkGun1");
                 insurance2[playerid] = dini_Int(house, "TrunkGun2");
                 insurance3[playerid] = dini_Int(house, "TrunkGun3");
                 insurance4[playerid] = dini_Int(house, "TrunkGun4");
                 insurance5[playerid] = dini_Int(house, "TrunkGun5");
                 printf("Load.....");
  }
  new str[255],str1[255];
  format(str1, sizeof(str1), "vehicles/%s.cfg", VehicleInfo[vehicleid][vOwner]);
  printf("vehicles/%s.cfg", VehicleInfo[vehicleid][vOwner]);
  if(dini_Exists(str1))
  {
     printf("Search for..");
     if(vehicleid == insurance1[playerid])
     {
         VehicleInfo[vehicleid][vW] -= 1;
         SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
         printf("Success");
     }
     else if(vehicleid == insurance2[playerid])
     {
        VehicleInfo[vehicleid][vW2] -= 1;
        SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
        printf("Success");
     }
     else if(vehicleid == insurance3[playerid])
     {
        VehicleInfo[vehicleid][vW3] -= 1;
        SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
        printf("Success");
     }
     else if(vehicleid == insurance4[playerid])
     {
        VehicleInfo[vehicleid][vW4] -= 1;
        SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
        printf("Success");
     }
     else if(vehicleid == insurance5[playerid])
     {
        VehicleInfo[vehicleid][vW5] -= 1;
        SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
        printf("Success");
     }
  }
}
First, the system should take info from the file of the owner, and then check which car he blows up, and then update it in vehicle file.
The problem in first part. its not load the "TrunkGun1" to "insurance1[playerid]"
What the problem?
Reply
#2

Any one ?
Reply
#3

Код:
if(dini_Exists(house))
House?
Reply
#4

Does the "Load..." print ever show up? Are you sure TrunkGun1 is set in the file and non-zero?
Reply
#5

i change the code to somthing like this: without dini:
pawn Код:
stock insurancedelete(vehicleid, playerid)
{
  new house[256];
  format(house, sizeof(house), "%s.ini",VehicleInfo[vehicleid][vOwner]);
  printf("%s.ini", VehicleInfo[vehicleid][vOwner]);
  new File: UserFile = fopen(house, io_read);
  if ( UserFile )
  {
   new PassData[256];
   new key[ 256 ];
   new val[ 256 ];
   new Data[ 256 ];
   fread( UserFile , Data , sizeof( Data ) );
   key = ini_GetKey( Data );
   if( strcmp( key , "TrunkGun1" , true ) == 0 ) { val = ini_GetValue( Data ); insurance1[playerid] = strval( val ); }
   if( strcmp( key , "TrunkGun2" , true ) == 0 ) { val = ini_GetValue( Data ); insurance2[playerid] = strval( val ); }
   if( strcmp( key , "TrunkGun3" , true ) == 0 ) { val = ini_GetValue( Data ); insurance3[playerid] = strval( val ); }
   if( strcmp( key , "TrunkGun4" , true ) == 0 ) { val = ini_GetValue( Data ); insurance4[playerid] = strval( val ); }
   if( strcmp( key , "TrunkGun5" , true ) == 0 ) { val = ini_GetValue( Data ); insurance5[playerid] = strval( val ); }
   fclose(UserFile);
   printf("Load.....");
  }
  fclose(UserFile);
  new str[255],str1[255];
  format(str1, sizeof(str1), "vehicles/%s.cfg", VehicleInfo[vehicleid][vOwner]);
  printf("vehicles/%s.cfg", VehicleInfo[vehicleid][vOwner]);
  if(dini_Exists(str1))
  {
     printf("Search for..");
     if(vehicleid == insurance1[playerid])
     {
         VehicleInfo[vehicleid][vW] -= 1;
         SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
         printf("Success");
     }
     else if(vehicleid == insurance2[playerid])
     {
        VehicleInfo[vehicleid][vW2] -= 1;
        SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
        printf("Success");
     }
     else if(vehicleid == insurance3[playerid])
     {
        VehicleInfo[vehicleid][vW3] -= 1;
        SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
        printf("Success");
     }
     else if(vehicleid == insurance4[playerid])
     {
        VehicleInfo[vehicleid][vW4] -= 1;
        SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
        printf("Success");
     }
     else if(vehicleid == insurance5[playerid])
     {
        VehicleInfo[vehicleid][vW5] -= 1;
        SendClientMessage(playerid, COLOR_LIGHTRED, "Vehicle Destroy");
        printf("Success");
     }
  }
}
Still didnt work well. i get the message Load and Search for..
but its not load the insurance part.
Reply
#6

TrunkGun1 should be the vehicleid. so its not zero, its like 37,40 somthing like this.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)