Show Vehicle Name Problem
#1

I have a text draw that shows the current location and vehicle name but I am having some trouble:

Код:
new VehNames[212][] = {	// Vehicle Names - Betamaster
	{"Landstalker"},
	{"Bravura"},
	{"Buffalo"},
	{"Linerunner"},
	{"Perrenial"},
	{"Sentinel"},
       ......more cars
	{"Utility Trailer"}
};
Код:
forward UpdateText(vehicleid);
Код:
stock GetVehicleModelIDFromName(vehname[])
{
	for(new i = 0; i < 211; i++)
	{
		if (strfind(VehNames[i], vehname, true) != -1) return i + 400;
	}
	return -1;
}
Код:
public UpdateText(vehicleid)
{
	for(new i=0; i<SLOTS;i++)
	  if(IsPlayerConnected(i))
	  {
	    new NEWTEXT[256];
	    new curv;
			GetVehicleModel(curv);
	    new car = GetVehicleModelIDFromName(vehicleid); <<<<<<Line 827
	    format(NEWTEXT,256, "Location: %s Vehicle: %s", GetPlayerArea(i),VehNames[GetVehicleModel(car)-400]);
			TextDrawSetString(Location[i], NEWTEXT);
		}
	return 1;
}
}
Код:
C:\Program Files\Rockstar Games\GTA San Andreas\SAMP\Server\filterscripts\LocDisplays.pwn(827) : error 035: argument type mismatch (argument 1)
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Error.
Reply
#2

Just use
pawn Код:
new NEWTEXT[256];
format(NEWTEXT,256, "Location: %s Vehicle: %s", GetPlayerArea(i),VehNames[GetVehicleModel(GetVehicleID(playerid))+400]);
TextDrawSetString(Location[i], NEWTEXT);
Reply
#3

Thanks for the reply. It compiles with no errors but it will not display the vehicle name.
I have also modified it to this:

pawn Код:
public UpdateText(playerid)
{
    for(new i=0; i<SLOTS;i++)
      if(IsPlayerConnected(i))
      {
        new NEWTEXT[256];
        if(IsPlayerInAnyVehicle(playerid))
                {
                    format(NEWTEXT,256, "Location: %s Vehicle: %s", GetPlayerArea(i),VehNames[GetVehicleModel(GetPlayerVehicleID(playerid))+400]);
                    TextDrawSetString(Location[i], NEWTEXT);
                }else{
                format(NEWTEXT,256, "Location: %s", GetPlayerArea(i));
                    TextDrawSetString(Location[i], NEWTEXT);
                }
        }
    return 1;
}
Anybody have any ideas on how to fix this, Thanks.
Reply
#4

What does it show?
Reply
#5

I have now fixed it, I think the problem was the "+400" when it should have been "-400"

This works:
pawn Код:
public UpdateText(playerid)
{
    for(new i=0; i<SLOTS;i++)
      if(IsPlayerConnected(i))
      {
        new NEWTEXT[256];
        if(IsPlayerInAnyVehicle(playerid))
                {
                  new VID = GetPlayerVehicleID(playerid);
                    format(NEWTEXT,256, "Location: %s Vehicle: %s", GetPlayerArea(i),VehNames[GetVehicleModel(VID)-400]);
                    TextDrawSetString(Location[i], NEWTEXT);
                }else{
                format(NEWTEXT,256, "Location: %s", GetPlayerArea(i));
                    TextDrawSetString(Location[i], NEWTEXT);
                }
        }
    return 1;
}
Thanks for the help JeNkStAX
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)