Something wrong
#1

Hello, I got 2 problems with my commands, its the same problem on the both commands. When i do /repair or /heal, it says you are not near that player. But i am really near. This is my codes. I cant understand whats wrong because it should be like that.

pawn Код:
CMD:repair(playerid,params[])
    {
        new targetid;
        new targetname[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
        GetPlayerName(targetid, targetname, sizeof(targetname));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        new Float:tx,Float:ty,Float:tz;
        GetPlayerPos(targetid,tx,ty,tz);
        new string[128];
        if(sscanf(params, "u[32]", targetid))
        return SendClientMessage(playerid, RED, "[LOST:RP] /repair [ID]");
        if(PlayerInfo[playerid][pTech] == 0)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not a Technican");
        if(IsPlayerNPC(targetid))
        return SendClientMessage(playerid, RED, "[LOST:RP] You cant repair things for NPCS");
        if(PlayerInfo[playerid][pOthers] == 1)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not in The Survivors Team");
        if(targetid == playerid)
        return SendClientMessage(playerid, RED, "[LOST:RP] You cant repair your own Walkie Talkie");
        if(!IsPlayerInRangeOfPoint(playerid, 6.0, tx,ty,tz))
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not near that player");
        if(PlayerInfo[targetid][pWalkieBroken] == 1)
        {
            GameTextForPlayer(playerid, "~g~Reparing Walkie Talkie",5,3000);
            new message = random(2);
            if(message == 0)
            {
                GameTextForPlayer(playerid, "~r~ You failed to repair that Walkie Talkie",5,3000);
                format(string, sizeof(string), "[DOCTOR] %s fails to repair %s's Walkie Talkie ", sendername, targetname);
                ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
            }
            if(message == 1)
            {
                GameTextForPlayer(playerid, "~g~You succeed to fix that walkie Talkie",5,3000);
                GameTextForPlayer(targetid, "~g~Fixed",5,3000);
                format(string, sizeof(string), "[DOCTOR] %s looses some screwes on the walkie talkie, and fixes it for %s ", sendername, targetname);
                ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
                PlayerInfo[targetid][pWalkieBroken] = 0;
            }
        }
        return 1;
    }
CMD:heal(playerid,params[])
    {
        new targetid;
        new targetname[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
        GetPlayerName(targetid, targetname, sizeof(targetname));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        new Float:tx,Float:ty,Float:tz;
        GetPlayerPos(targetid,tx,ty,tz);
        new string[128];
        if(sscanf(params, "u[32]", targetid))
        return SendClientMessage(playerid, RED, "[LOST:RP] /heal [ID]");
        if(PlayerInfo[playerid][pDoctor] == 0)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not a doctor");
        if(IsPlayerNPC(targetid))
        return SendClientMessage(playerid, RED, "[LOST:RP] You cant heal NPCS");
        if(PlayerInfo[playerid][pOthers] == 1)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not in The Survivors Team");
        if(targetid == playerid) return SendClientMessage(playerid, RED, "[LOST:RP] You cant heal yourself");
        if(!IsPlayerInRangeOfPoint(playerid, 6.0, tx,ty,tz))
        return SendClientMessage(playerid, RED, "[LOST:RP] You arent close to that player");
        {
            GameTextForPlayer(playerid, "~g~Healing Player",5,3000);
            new message = random(2);
            if(message == 0)
            {
                GameTextForPlayer(playerid, "~r~ You failed to heal that player",5,3000);
                format(string, sizeof(string), "[DOCTOR] %s fails to heal %s ", sendername, targetname);
                ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
            }
            if(message == 1)
            {
                GameTextForPlayer(playerid, "~g~You succeed to heal that player",5,3000);
                GameTextForPlayer(targetid, "~g~Healed",5,3000);
                format(string, sizeof(string), "[DOCTOR] %s takes some bandage and wraps it around %s ", sendername, targetname);
                ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
                SetPlayerHealth(targetid, 100);
            }
        }
        return 1;
    }
Reply
#2

Look at the sscanf line's
pawn Код:
"u[32]"
change that to
pawn Код:
"u"
And put the "GetPlayerName" && GetPlayerPos inder the sscanf line, because i think it gets buggy and targetid returns to playerid 0, but im not sure
Reply
#3

it didnt work :S
Reply
#4

This is the new code

pawn Код:
CMD:heal(playerid,params[])
    {
        new targetid;
        new targetname[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
        GetPlayerName(targetid, targetname, sizeof(targetname));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        new Float:tx,Float:ty,Float:tz;
        GetPlayerPos(targetid,tx,ty,tz);
        new string[128];
        if(sscanf(params, "u", targetid))
        return SendClientMessage(playerid, RED, "[LOST:RP] /heal [ID]");
        if(PlayerInfo[playerid][pDoctor] == 0)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not a doctor");
        if(IsPlayerNPC(targetid))
        return SendClientMessage(playerid, RED, "[LOST:RP] You cant heal NPCS");
        if(PlayerInfo[playerid][pOthers] == 1)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not in The Survivors Team");
        if(targetid == playerid) return SendClientMessage(playerid, RED, "[LOST:RP] You cant heal yourself");
        if(!IsPlayerInRangeOfPoint(playerid, 6.0, tx,ty,tz))
        return SendClientMessage(playerid, RED, "[LOST:RP] You arent close to that player");
        {
            GameTextForPlayer(playerid, "~g~Healing Player",5,3000);
            new message = random(2);
            if(message == 0)
            {
                GameTextForPlayer(playerid, "~r~ You failed to heal that player",5,3000);
                format(string, sizeof(string), "[DOCTOR] %s fails to heal %s ", sendername, targetname);
                ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
            }
            if(message == 1)
            {
                GameTextForPlayer(playerid, "~g~You succeed to heal that player",5,3000);
                GameTextForPlayer(targetid, "~g~Healed",5,3000);
                format(string, sizeof(string), "[DOCTOR] %s takes some bandage and wraps it around %s ", sendername, targetname);
                ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
                SetPlayerHealth(targetid, 100);
            }
        }
        return 1;
    }

CMD:repair(playerid,params[])
    {
        new targetid;
        new targetname[MAX_PLAYER_NAME], sendername[MAX_PLAYER_NAME];
        GetPlayerName(targetid, targetname, sizeof(targetname));
        GetPlayerName(playerid, sendername, sizeof(sendername));
        new Float:x,Float:y,Float:z;
        GetPlayerPos(playerid,x,y,z);
        new Float:tx,Float:ty,Float:tz;
        GetPlayerPos(targetid,tx,ty,tz);
        new string[128];
        if(sscanf(params, "u", targetid))
        return SendClientMessage(playerid, RED, "[LOST:RP] /repair [ID]");
        if(PlayerInfo[playerid][pTech] == 0)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not a Technican");
        if(IsPlayerNPC(targetid))
        return SendClientMessage(playerid, RED, "[LOST:RP] You cant repair things for NPCS");
        if(PlayerInfo[playerid][pOthers] == 1)
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not in The Survivors Team");
        if(targetid == playerid)
        return SendClientMessage(playerid, RED, "[LOST:RP] You cant repair your own Walkie Talkie");
        if(!IsPlayerInRangeOfPoint(playerid, 6.0, tx,ty,tz))
        return SendClientMessage(playerid, RED, "[LOST:RP] You are not near that player");
        if(PlayerInfo[targetid][pWalkieBroken] == 1)
        {
            GameTextForPlayer(playerid, "~g~Reparing Walkie Talkie",5,3000);
            new message = random(2);
            if(message == 0)
            {
                GameTextForPlayer(playerid, "~r~ You failed to repair that Walkie Talkie",5,3000);
                format(string, sizeof(string), "[DOCTOR] %s fails to repair %s's Walkie Talkie ", sendername, targetname);
                ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
            }
            if(message == 1)
            {
                GameTextForPlayer(playerid, "~g~You succeed to fix that walkie Talkie",5,3000);
                GameTextForPlayer(targetid, "~g~Fixed",5,3000);
                format(string, sizeof(string), "[DOCTOR] %s looses some screwes on the walkie talkie, and fixes it for %s ", sendername, targetname);
                ProxDetector(30.0, playerid, string, COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN,COLOR_GREEN);
                PlayerInfo[targetid][pWalkieBroken] = 0;
            }
        }
        return 1;
    }
Reply
#5

Quote:
Originally Posted by CyberGhost
And put the "GetPlayerName" && GetPlayerPos under the sscanf line, because i think it gets buggy and targetid returns to id 0, but im not sure
^ That
Reply
#6

Oh sorry didnt see that! Thanks, i will try
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)