[HELP] Creating a new command...
#1

Hey again. I've created a command to get off from "auto-crack" (Automaticly sent in "CRACK" animation and frozen if health under 20).

Well, it compiles it with 2 new warnings, but no effect IG. Here's the warnings, and code:

[PAWNO]E:\SA-MP Offical Server\gamemodes\B-RP.pwn(45426) : warning 235: public function lacks forward declaration (symbol "GetUp")
E:\SA-MP Offical Server\gamemodes\B-RP.pwn(45429) : warning 202: number of arguments does not match definition[/PAWNO]

[PAWNO]public GetUp(playerid)
{
new cmd[256];
cmd = strtok(cmd);
if(strcmp(cmd, "/getup", true) == 0)
{
new Float:health;
GetPlayerHealth(playerid,health);
if(health <= 20)
{
SetPlayerHealth(playerid, 25);
TogglePlayerControllable(playerid,1);
}
}
return 1;
}
[/PAWNO]

P.S. If anyone is interested, you can add there a timer for /getup. (1,5 minutes timer) Not needed tho, but if want, go ahead!
Reply
#2

at linfe 45426 forward it

EXAMPLE
forward GivePlayerMoneyEx(playerid,ammount);
public GivePlayerMoneyEx(playerid,ammount);

so it would be
forward GetUp(playerid)
public GetUp(playerid)
Reply
#3

pawn Code:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if( strcmp( cmdtext, "/getup", true, 6 ) == 0 ) {
        SetTimerEx( "GetUp", 90000, 0, "i", playerid );
        return 1;
    }
    return 0;
}

forward GetUp( playerid );
public GetUp( playerid )
{
    new
        Float:health;

    GetPlayerHealth( playerid, health );
    if( health <= 20 ) {
        SetPlayerHealth( playerid, 25 );
        TogglePlayerControllable( playerid, 1 );
    }
    return 1;
}
Reply
#4

Quote:
Originally Posted by Dwane
View Post
pawn Code:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if( strcmp( cmdtext, "/getup", true, 6 ) == 0 ) {
        SetTimerEx( "GetUp", 90000, 0, "i", playerid );
        return 1;
    }
    return 0;
}

forward GetUp( playerid );
public GetUp( playerid )
{
    new
        Float:health;

    GetPlayerHealth( playerid, health );
    if( health <= 20 ) {
        SetPlayerHealth( playerid, 25 );
        TogglePlayerControllable( playerid, 1 );
    }
    return 1;
}
Thats basiclly an exact copy of what I siad.
Reply
#5

Quote:
Originally Posted by milanosie
View Post
Thats basiclly an exact copy of what I siad.
It's totally different, because you told him to add the forward but still that won't work
pawn Code:
forward GetUp(playerid);                          // <-
public GetUp(playerid)
{
    new cmd[256];
    cmd = strtok(cmd);
    if(strcmp(cmd, "/getup", true) == 0) {
        new Float:health;
        GetPlayerHealth(playerid,health);
        if(health <= 20) {
            SetPlayerHealth(playerid, 25);
            TogglePlayerControllable(playerid,1);
        }
    }
    return 1;
}
// Thats wrong because all the command inside the custom callback will be undefined symbols.
Reply
#6

Well I asumed he already defined it.
Reply
#7

Well this went funny... My auto-crack is bugging possibly because of this.

My ID was 0 IG, and i were the only one abled to go in it, after lower than 20 HP. /getup, nonono, doesn't work. With any of those. O.o

pawn Code:
forward CheckHealth(playerid);
public CheckHealth(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid,health);
    if(health <= 20)
    {
        ApplyAnimation(playerid, "ped", "KO_spin_L", 4.1, 1, 1, 1, 1, 1, 1);
        TogglePlayerControllable(playerid,0);
    }
    return 1;
}
Reply
#8

pawn Code:
forward CheckHealth();
public CheckHealth()
{
for(new i = 0; i < MAX_PLAYERS; i++)
  {
    new Float:health;
    GetPlayerHealth(i,health);
    if(health <= 20)
     {
        ApplyAnimation(i, "ped", "KO_spin_L", 4.1, 1, 1, 1, 1, 1, 1);
        TogglePlayerControllable(i,0);
     }
   }
   return 1;
}
Not tested though..anyways would be better to use OnPlayerUpdate for health checking since it checks health very frequently
Reply
#9

Quote:
Originally Posted by mSp
View Post
pawn Code:
forward CheckHealth();
public CheckHealth()
{
for(new i = 0; i < MAX_PLAYERS; i++)
  {
    new Float:health;
    GetPlayerHealth(i,health);
    if(health <= 20)
     {
        ApplyAnimation(i, "ped", "KO_spin_L", 4.1, 1, 1, 1, 1, 1, 1);
        TogglePlayerControllable(i,0);
     }
   }
   return 1;
}
Not tested though..anyways would be better to use OnPlayerUpdate for health checking since it checks health very frequently
Ok... We tested it with 2 people, and now it works for everyone. But one question - How the heck my character keeps doing the animation all the time? It spins like 2 times in a second.. I think it's because of this?
pawn Code:
HealthTimer = SetTimer("CheckHealth",500, true);
That's under OnGameModeInIt.
Reply
#10

Quote:
Originally Posted by Da' J'
View Post
Ok... We tested it with 2 people, and now it works for everyone. But one question - How the heck my character keeps doing the animation all the time? It spins like 2 times in a second.. I think it's because of this?
pawn Code:
HealthTimer = SetTimer("CheckHealth",500, true);
That's under OnGameModeInIt.
Have you checked your applyanimation parameters?
https://sampwiki.blast.hk/wiki/ApplyAnimation

And btw if you're missing still missing the /getup cmd
pawn Code:
public OnPlayerCommandText( playerid, cmdtext[ ] )
{
    if( strcmp( cmdtext, "/getup", true, 6 ) == 0 ) {
        SetPlayerHealth(playerid, 25);
        ClearAnimations(playerid);
        TogglePlayerControllable(playerid,1);
        return 1;
    }
    return 0;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)