One off command
#1

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
Reply
#2

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;
}
Reply
#3

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;
    }
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)