SA-MP Forums Archive
Car id command - 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: Car id command (/showthread.php?tid=159662)



Car id command - robert4049 - 14.07.2010

how would i make a command telling you the car id like

/carid
sendclient message your car id is %

how would this be done?


Re: Car id command - Faith - 14.07.2010

pawn Код:
if(strcmp(cmd, "/carid", true) == 0) {

if(!IsPlayerInAnyVehicle(playerid)){
SendClientMessage(playerid, red, "You need to be in a car to use this command.");
return 1;
}

new vehicleid = GetPlayerVehicleID(playerid);
new string[128];

format(string, sizeof(string), "Your car id is %d", vehicleid);
SendClientMessage(playerid, yellow, string);
return 1;
}
Sorry for the no-identation, written from Ipod touch.


Re: Car id command - robert4049 - 14.07.2010

thanks mate
edit but in the end i get this

Код:
C:\Users\Robert\Desktop\SA-MP\gamemodes\crp.pwn(9019) : warning 219: local variable "string" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase

Header size:           6304 bytes
Code size:           561580 bytes
Data size:          1372116 bytes
Stack/heap size:      16384 bytes; estimated max. usage=4086 cells (16344 bytes)
Total requirements: 1956384 bytes

1 Warning.



Re: Car id command - RichyB - 14.07.2010

LOL?

Its because string has already been identified.
Remove the following from the /carid.
pawn Код:
new string[128];
Instead to make it easier, copy this and replace the last one with it.
pawn Код:
if(strcmp(cmd, "/carid", true) == 0) {

if(!IsPlayerInAnyVehicle(playerid)){
SendClientMessage(playerid, red, "You need to be in a car to use this command.");
return 1;
}

new vehicleid = GetPlayerVehicleID(playerid);

format(string, sizeof(string), "Your car id is %d", vehicleid);
SendClientMessage(playerid, yellow, string);
return 1;
}
No Errors should show.