One off 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)
+--- Thread: One off command (
/showthread.php?tid=335951)
One off command -
Toshh - 20.04.2012
Hey Guys
I made a basic command which allows the player to spawn an infernus infront of themselves.
Is there any way I can make the command usable once per life?
the code for the command is
Код:
if(strcmp("/inf", cmdtext, true, 4) == 0)
{
new Float:X, Float:Y, Float:Z, Float:Ang;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
GetPlayerFacingAngle(playerid, Float:Ang);
CreateVehicle(411, X - 4.0, Y, Z, Ang + 90.0, -1, -1, 5000);
return 1;
}
Thanks once again
Re: One off command -
WLSF - 20.04.2012
Try this:
pawn Код:
new bool:c_var_death[MAX_PLAYERS];
if(!strcmp(cmdtext, "/infernus", true))
{
if(c_var_death[playerid])
return SendClientMessage(playerid, -1, "You need to die before creating another infernus!");
new Float:pos[4];
GetPlayerPos(playerid, pos[0], pos[1], pos[2]);
GetPlayerFacingAngle(playerid, pos[3]);
CreateVehicle(411, pos[0], pos[1], pos[2], pos[3], -1, -1, 9999999);
c_var_death[playerid] = true;
return 1;
}
public OnPlayerDeath(playerid, killerid, reason)
{
return c_var_death[playerid] = false;
}
Re: One off command -
[MG]Dimi - 20.04.2012
pawn Код:
if(strcmp("/inf", cmdtext, true, 4) == 0)
{
new Float:X, Float:Y, Float:Z, Float:Ang;
GetPlayerPos(playerid, Float:X, Float:Y, Float:Z);
GetPlayerFacingAngle(playerid, Float:Ang);
CreateVehicle(411, X - 4.0, Y, Z, Ang + 90.0, -1, -1, 5000);
return 1;
}
Only wrong thing is that you don't need to put tag Float when using it in function.
Fixed code:
pawn Код:
if(strcmp("/inf", cmdtext, true, 4) == 0)
{
new Float:X, Float:Y, Float:Z, Float:Ang;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, Ang);
CreateVehicle(411, X - 4.0, Y, Z, Ang + 90.0, -1, -1, 5000);
return 1;
}