How the hell? - Need help
#1

Removed all.
Reply
#2

Quote:
Originally Posted by Andregood
Посмотреть сообщение
Look, I've defined gTeam and RACE_VAMPIRES 2 (1 is humans)


And still when I setrace 2 it doesn't work..


Код:
CMD:vampirebite(playerid, params[]) {
    if(gTeam(playerid) != 2) return SendClientMessage(playerid, 0xAFAFAFAA, "You need to be a vampire to use this command"); // Checks if the team is RACE_VAMPIRES. If not, it returns the message that you have to be one.

    new pID; // Self-explanatory

    if(sscanf(params, "u", pID)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage : /vampirebite [playerid/name]");
    if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid, 0xAFAFAFAA, "That player is currently not connected."); // Checks whether the ID is valid/connected

	new Float:hp;
	GetPlayerHealth(pID, hp);
	hp -= 30.0;
	SetPlayerHealth(pID, hp);

    return SendClientMessage(pID, 0xAFAFAFAA, "You've been bitten"); //After all the checks are done, sends this message if they all are passed.
 }
It compiles and all but when I do /vampirebite it merely says "You need to be a vampire to use this command"... Please help me, thanks
I'm figuring your /setrace command is flawed. Can you post that here aswell?
Reply
#3

Yea of course mate.


Код:
command(setrace, playerid, params[])
{
    new pID, tID;
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xAFAFAFAA, "You need to be an rcon administrator to use this command");
    if(sscanf(params, "ui", pID, tID)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage : /setrace [playerid/name] [teamid]");
    if(!IsPlayerConnected(pID)) return SendClientMessage(playerid, 0xAFAFAFAA, "This player is not connected.");
    SetPlayerTeam(pID, tID);
    return SendClientMessage(playerid,0xAFAFAFAA, "Changed the player's race");
    }
Reply
#4

Is 'gTeam' an array or a function?
Reply
#5

A function originally I guess, then my mate fixed the whole snippet up but it still didn't work although it was nearly perfect and still is, if you ask me. I'm rather new so..
Reply
#6

I went ahead and rebuilt your commands.. Tell me if it works.

pawn Код:
COMMAND:vampirebite(playerid, params[])
{
    new
        Player;

    if(sscanf(params, "u", Player)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage : /vampirebite [playerid/name]");
    if(Player != INVALID_PLAYER_ID) {
        new Float:hp;
        GetPlayerHealth(Player, hp);
        SetPlayerHealth(Player, hp=-30);
    }
    else return SendClientMessage(playerid, 0xAFAFAFAA, "That player is currently not connected.");
    return 1;
}
pawn Код:
COMMAND:setrace(playerid, params[])
{
    new
        Player,
        TeamID;
       
    if(sscanf(params, "ud", Player, TeamID)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage : /setrace [playerid/name] [teamid]");
    if(IsPlayerAdmin(playerid)) {
        if(Player != INVALID_PLAYER_ID) {
            SetPlayerTeam(Player, TeamID);
            SendClientMessage(playerid,0xAFAFAFAA, "Changed the player's race");
        }
        else return SendClientMessage(playerid, 0xAFAFAFAA, "This player is not connected.");
    }
    else return SendClientMessage(playerid, 0xAFAFAFAA, "You need to be an rcon administrator to use this command");
    return 1;
}
Reply
#7

Then probably you don't know what I'm talking about, a function can be a stock, for example:
pawn Код:
stock My_Function()
{
    return printf("Hello, My_Function() was called!");
}
Whilst an array is a variable with a determinated size and can hold multiple information or data.
pawn Код:
new Array[4];
Array[0] = 555;
Array[1] = 444;
Array[2] = 467;
Array[3] = 488;
printf("Array0:%d, Array1:%d, Array2:%d, Array3:%d", Array[0], Array[1], Array[2], Array[3]);

new Team[MAX_PLAYERS]; // MAX_PLAYERS is pre-defined as 500.
Do you have something anywhere to be near "new gTeam[MAX_PLAYERS];" in your script?
Reply
#8

YES! It works, thank you so much! I'll give you credits for it of course, if you only knew how important that command is, thank you!




And I am rather new to scripting so I'm not that fluent, so thanks for that as well!
Reply
#9

Even non-vampire players will be allowed to bite.
Reply
#10

Quote:
Originally Posted by Andregood
Посмотреть сообщение
YES! It works, thank you so much! I'll give you credits for it of course, if you only knew how important that command is, thank you!




And I am rather new to scripting so I'm not that fluent, so thanks for that as well!
Not a problem, try using your braces instead of return statements, it helps your code, it may be longer, but it makes for less mistakes in the long run.

Just noticed that, admantis.

pawn Код:
COMMAND:vampirebite(playerid, params[])
{
    new
        Player;

    if(sscanf(params, "u", Player)) return SendClientMessage(playerid, 0xAFAFAFAA, "Usage : /vampirebite [playerid/name]");
    if(Player != INVALID_PLAYER_ID) {
        if(gTeam[playerid] == 2) {
            new Float:hp;
            GetPlayerHealth(Player, hp);
            SetPlayerHealth(Player, hp=-30);
        }
        else return SendClientMessage(playerid, 0xAFAFAFAA, "You need to be a vampire to use this command");
    }
    else return SendClientMessage(playerid, 0xAFAFAFAA, "That player is currently not connected.");
    return 1;
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)