/getcar problem. Only spawns car IDs up to 3 or 4 - 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: /getcar problem. Only spawns car IDs up to 3 or 4 (
/showthread.php?tid=274753)
/getcar problem. Only spawns car IDs up to 3 or 4 [FIXED!] -
Sledge - 07.08.2011
Hi, here is my /getcar CMD. This spawns car IDs to the users location. The only problem is it only spawns up to car ID 2. We had 3 players online at the time we tested the command.
pawn Код:
CMD:getcar(playerid, params[]) {
if(playerVariables[playerid][pAdminLevel] >= 3)
{
new vehid,messageString[64],logString[64],Float:x, Float:y, Float:z, Float:vehx, Float:vehy, Float:vehz;
if(sscanf(params, "u", vehid))
{
SendClientMessage(playerid, COLOR_GREY, SYNTAX_MESSAGE"/getcar [vehicleid]");
return 1;
}
if(vehid != INVALID_VEHICLE_ID)
{
GetPlayerPos(playerid, x, y, z);
GetVehiclePos(vehid, vehx, vehy, vehz);
SetVehiclePos(vehid, x, y+4, z+1);
SetVehicleVirtualWorld(vehid, GetPlayerVirtualWorld(playerid));
LinkVehicleToInterior(vehid, GetPlayerInterior(playerid));
format(messageString, sizeof(messageString), "You have teleported car ID {CD0000}%d{FFFFFF} to your location.", vehid);
SendClientMessage(playerid, COLOR_WHITE, messageString);
format(logString, sizeof(logString), "%s has teleported car ID %d (coords: %d, %d, %d)", playerVariables[playerid][pNormalName], vehid, vehx, vehy, vehz);
mysql_real_escape_string(logString, logString);
adminLog(logString);
}
else
{
SendClientMessage(playerid, COLOR_GREY, "Invalid vehicle ID.");
}
}
return 1;
}
Re: /getcar problem. Only spawns car IDs up to 3 or 4 -
Calgon - 07.08.2011
Replace 'u' with 'd' in your sscanf line. You're making sscanf rely on player IDs and names, as opposed to integers/digits which is what a vehicle id is in sscanf - it doesn't have a special parameter, it's just an average digit/integer.
Re: /getcar problem. Only spawns car IDs up to 3 or 4 -
[HiC]TheKiller - 07.08.2011
You should be using d or i for the sscanf string.
Re: /getcar problem. Only spawns car IDs up to 3 or 4 -
Sledge - 07.08.2011
I was looking into that. When I compared this with other codes (the sscanf part), it looked right. Thank you.