Author Topic: Can anyone help me ??  (Read 2288 times)

0 Members and 1 Guest are viewing this topic.

Offline 97martin

  • Street Thug
  • *
  • Posts: 1
    • View Profile
Can anyone help me ??
« on: October 04, 2012, 09:16:04 am »
hi.
can anyone help me how to make when player enters vehicle if vehicle not for sale to send him a message : id :"vehicleid here", price:Not For Sale, Owner:"vehicle owner".
and if vehicle for sale send him a message : id :"vehicleid here", price:"any price here", Owner:"vehicle owner".
i'm using gups.
i added this to onplayerentervehicle[pawn]new szMsg[128], nfs[128];
      nfs = "nfs";
      if(VehicleInfo[vehicleid][Price] == nfs)
      {
      format(szMsg, 128, "ID: %d, Price: Not For Sale, Owner: %s", VehicleInfo[vehicleid][Id], VehicleInfo[vehicleid][Owner]);
      SendClientMessage(playerid, GREEN, szMsg);
      }
      else if(VehicleInfo[vehicleid][Price] != nfs)
      {
      format(szMsg, 128, "ID: %d, Price: $%d, Owner: %s", VehicleInfo[vehicleid][Id], VehicleInfo[vehicleid][Price], VehicleInfo[vehicleid][Owner]);
      SendClientMessage(playerid, GREEN, szMsg);
      }[/pawn]
but when compiling it shows me 2 errors
[pawn]C:\Users\user\Desktop\VCMP Server\gamemodes\GUPS1.16old.pwn(254) : error 033: array must be indexed (variable "nfs")
C:\Users\user\Desktop\VCMP Server\gamemodes\GUPS1.16old.pwn(259) : error 033: array must be indexed (variable "nfs")
Pawn compiler 3.0.3367         Copyright (c) 1997-2005, ITB CompuPhase


2 Errors.
[/pawn]
Sorry for my bad english!!!
« Last Edit: October 04, 2012, 09:19:21 am by 97martin »

Offline FR0ST4BL3

  • Street Thug
  • *
  • Posts: 2
    • View Profile
Re: Can anyone help me ??
« Reply #1 on: October 05, 2012, 12:43:21 am »
Use the following code:
[pawn]public OnPlayerEnterVehicle(playerid,vehicleid)
{
      if ( !IsVehicleForSale(vehicleid) )
      {
         new id, szMsg[ 128 ];
           id = GetPlayerVehicleID( playerid );
         format( szMsg, sizeof( szMsg ), "ID: %d | Vehicle owner: %s | Shared: %s", id, VehicleInfo[ id ][ Owner ], VehicleInfo[ id ][ Share ] );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      else
      {
         new id, szMsg[ 128 ];
         id = GetPlayerVehicleID( playerid );
         format( szMsg, sizeof( szMsg ), "**pm >> You have $%d? Type !buycar %d", VehicleInfo[ id ][ Price ], id );
         SendClientMessage( playerid, COLOR_GREEN, szMsg );
      }
      return 1;
}[/pawn]