Car id command
#1

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

/carid
sendclient message your car id is %

how would this be done?
Reply
#2

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.
Reply
#3

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.
Reply
#4

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)