SA-MP Forums Archive
How to creat a vehicle with ZCMD+sscanf - 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: How to creat a vehicle with ZCMD+sscanf (/showthread.php?tid=248624)



How to creat a vehicle with ZCMD+sscanf - VivianKris - 15.04.2011

How to creat a vehicle with ZCMD+sscanf?
Hello everybody, i want to creat a car with it, but how?

this is my code.

Код:
CMD:acar(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在不登陆的情况下使用。");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在车内使用。");
	new vid;
	if(sscanf(params, "u", vid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]使用方法:/acar (vid)");
	if(vid < 400 || vid > 600) return SendClientMessage(playerid, COLOR_GREY, "[提示]无效的车辆ID,请查阅Wiki。");
	new Float:x, Float:y, Float:z;
	GetPlayerPos(playerid, x, y, z);
	CreateVehicle(vid, x, y, z, 0, 0, 0, 0);
	return 1;
}
my code cant run, if you add it in a FS, this FS is invalid.


Re: How to creat a vehicle with ZCMD+sscanf - Skylar Paul - 15.04.2011

pawn Код:
CMD:acar(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在不登陆的情况下使用。");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在车内使用。");
    new vid;
    if(sscanf(params, "i", vid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]使用方法:/acar (vid)");
    if(vid < 400 || vid > 600) return SendClientMessage(playerid, COLOR_GREY, "[提示]无效的车辆ID,请查阅Wiki。");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(vid, x, y, z, 0, 0, 0, 0);
    return 1;
}
"u" is used for player-based commands, "u" = user, I suggest you check the sscanf documentation.

Quote:

This forum requires that you wait 120 seconds between posts. Please try again in 21 seconds.

God damn...


Re: How to creat a vehicle with ZCMD+sscanf - Tee - 15.04.2011

This is ok but it will create the vehicle at the players positions and that can be annoying. So here is what i did:

pawn Код:
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在不登陆的情况下使用。");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在车内使用。");
    new vid;
    if(sscanf(params, "i", vid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]使用方法:/acar (vid)");
    if(vid < 400 || vid > 600) return SendClientMessage(playerid, COLOR_GREY, "[提示]无效的车辆ID,请查阅Wiki。");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(vid, x+2, y, z+2, 0, 0, 0, 0);
    return 1;
}
I just added +2 to x and z. That should create the vehicle further from the player.


Re: How to creat a vehicle with ZCMD+sscanf - Lorenc_ - 15.04.2011

Quote:
Originally Posted by Tee
Посмотреть сообщение
This is ok but it will create the vehicle at the players positions and that can be annoying. So here is what i did:

pawn Код:
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在不登陆的情况下使用。");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在车内使用。");
    new vid;
    if(sscanf(params, "i", vid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]使用方法:/acar (vid)");
    if(vid < 400 || vid > 600) return SendClientMessage(playerid, COLOR_GREY, "[提示]无效的车辆ID,请查阅Wiki。");
    new Float:x, Float:y, Float:z;
    GetPlayerPos(playerid, x, y, z);
    CreateVehicle(vid, x+2, y, z+2, 0, 0, 0, 0);
    return 1;
}
I just added +2 to x and z. That should create the vehicle further from the player.
Instead of that they could inject a code
PutPlayerInVehicle(playerid, vid);
I'm pretty sure theres another parameter I'm missing


Re: How to creat a vehicle with ZCMD+sscanf - Skylar Paul - 15.04.2011

Quote:
Originally Posted by Lorenc_
Посмотреть сообщение
Instead of that they could inject a code
PutPlayerInVehicle(playerid, vid);
I'm pretty sure theres another parameter I'm missing
Yup, just put them in seatid zero.

pawn Код:
PutPlayerInVehicle(playerid, vid, 0);



Re: How to creat a vehicle with ZCMD+sscanf - VivianKris - 15.04.2011

Thanks all of you for helping me to solve the question.
now i can run it !


Re: How to creat a vehicle with ZCMD+sscanf - VivianKris - 15.04.2011

I write it again.
Код:
CMD:acar(playerid, params[])
{
    if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在不登陆的情况下使用。");
    if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]此命令无法在车内使用。");
	new vid, vcar;
	if(sscanf(params, "i", vid)) return SendClientMessage(playerid, COLOR_GREY, "[提示]使用方法:/acar (vid)");
	if(vid < 400 || vid > 600) return SendClientMessage(playerid, COLOR_GREY, "[提示]无效的车辆ID,请查阅Wiki。");
	new Float:x, Float:y, Float:z, Float:angle;
	GetPlayerPos(playerid, x, y, z);
	GetPlayerFacingAngle(playerid, angle);
	vcar = CreateVehicle(vid, x, y, z, angle, 0, 0, 0);
	PutPlayerInVehicle(playerid, vcar, 0);
	return 1;
}