SA-MP Forums Archive
Insurance system - 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: Insurance system (/showthread.php?tid=171381)



Insurance system - vection - 26.08.2010

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?


Re: Insurance system - vection - 26.08.2010

Any one ?


Re: Insurance system - armyoftwo - 26.08.2010

Код:
if(dini_Exists(house))
House?


Re: Insurance system - woot - 26.08.2010

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


Re: Insurance system - vection - 26.08.2010

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.


Re: Insurance system - vection - 26.08.2010

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