What happend
#1

I've created a command when someone enterd the race checkpoint the enemy player must die but When I enterd the race checkpoint I died not the enemy player why?

PHP код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
    if(
CompleteKidnap[playerid] == 1)
    {
        new 
string[256];
        new 
targetid,tName[MAX_PLAYER_NAME];
        
GetPlayerName(targetidtNamesizeof(tName));
        
SetPlayerHealth(targetid0.0);
        
GivePlayerMoney(playeridMoney[playerid]);
        
format(stringsizeof(string), "{0BEA00}[Kidnapping]: {FFFFFF}Player {FF9F00}%s(%d) {FFFFFF}has dead by the {E33667}Kidnapping {FFFFFF}by user {FF9F00}%s(%d){FFFFFF}."tName,targetidPlayerName(playerid), playerid);
        
SendClientMessageToAll(-1string);
        
format(stringsizeof(string), "{0BEA00}[Money]:{FFFFFF} You have killed {FF9F00}%s(%d) {FFFFFF}by the {E33667}Kidnapping {FFFFFF}and you {E33667}Received{FFFFFF}:{0BEA00}$%d{FFFFFF}."TargetName(targetid),targetidMoney[playerid]);
        
SendClientMessage(playerid, -1string);
        
CompleteKidnap[playerid] = 0;
        
DisablePlayerRaceCheckpoint(playerid);
        
GameTextForPlayer(targetid"~N~~N~~R~DEAD BY THE ~Y~KIDNAPPING~R~.."5000 5);
        
GameTextForPlayer(playerid"~N~~N~~G~COMPLETED~R~.."5000 5);
    }
    return 
1;

Reply
#2

wtf is this thing you are creating just variable targetid and doesn't even set value who is target?
Reply
#3

lol so how to do that?
Reply
#4

show your command where you set player as a target
Reply
#5

Here you go buddy.

PHP код:
CMD:kidnap(playeridparams[])
{
    new 
string[256];
    if(
IsPlayerSpawned[playerid]) return SendClientMessage(playeridCOLOR_RED"[ERROR]: You must be spawned to use that command.");
    new 
tName[MAX_PLAYER_NAME],targetid,pName[MAX_PLAYER_NAME],Value;
    
GetPlayerName(targetidtNamesizeof(tName));
    
GetPlayerName(playeridpNamesizeof(pName));
    if(
sscanf(params"uds[50]"targetidValue)) return SendClientMessage(playerid, -1"{189381}USAGE: {FFFFFF}/kidnap [ID] [Value]");
    if(
targetid == INVALID_PLAYER_ID) return SendClientMessage(playerid0xFFFFFFFF"{FF0000}Error: {FFFFFF}That player is not connected!");
    if(
Value 24999)
    {
        if(
IsPlayerInAnyVehicle(playerid))
        {
              if(
GetPlayerState(playerid) == PLAYER_STATE_DRIVER && GetPlayerState(targetid) == PLAYER_STATE_PASSENGER)
             {
                 if(
kdinaptime[playerid] == 0)
                {
                     
Money[targetid] = Value;
                      
TogglePlayerControllable(targetid0);
                    
format(string,sizeof(string), "{E33667}[Kidnapping]: {FFFFFF}Player {E33667}%s(%d) {FFFFFF}has been {E33667}KIDNAPPING {FFFFFF}by {E33667}%s(%d){FFFFFF}. Value Amount: {E33667}$%d{FFFFFF}."tName,targetidpName,playerid,Value);
                     
SendClientMessageToAll(COLOR_REDstring);
                     
                     
format(string,sizeof(string), "{E33667}[Kidnapping]: You have been Kidnapping by %s(%d)."pName,playerid);
                    
SendClientMessage(targetid, -1string);
                    
                    new 
rand random(sizeof(KidnappingPos));
                    
SetPlayerRaceCheckpoint(playerid1KidnappingPos[rand][0],KidnappingPos[rand][1],KidnappingPos[rand][2], 0,0,03);
                    
CompleteKidnap[playerid] = 1;
                    
SetPlayerWantedLevel(playeridGetPlayerWantedLevel(playerid) + 4);
                    
SetPlayerColor(playeridCOLOR_ORANGE);
                    
GameTextForPlayer(targetid"~Y~You ~p~are ~r~Kidnapping..."100005);
                    
GameTextForPlayer(playerid"~r~Kidnapping..."100005);
                    
SetTimerEx("antispamkid"ANTISPAM_TIME*60000false"d"playerid);
                }
                else
                {
                    
SendClientMessage(playerid, -1"{FF0000}Error: {FFFFFF}Please wait before kidnapping other's players.");
                }
            }
            else
                {
                    
SendClientMessage(playerid, -1"{FF0000}Error: {FFFFFF}You are not in any vehicle.");
                }
        }
        else
        {
            
SendClientMessage(playerid, -1"{FF0000}Error: {FFFFFF}You must be a driver and enemy player must be passenger.");
        }
    }
    else
    {
         
SendClientMessage(playerid, -1"{FF0000}Error: {FFFFFF}Minimum amount to Set a Price of kidnapping a person with is +$25.000!");
    }
    return 
1;

Reply
#6

PHP код:
new PlayerIsTargetedBy[MAX_PLAYERS]={-1,...};
CMD:kidnap(pid,p[]){
    new 
userid;
    if(
sscanf(p,"u",userid))return SendClientMessage(pid,-1,"/kidnap [playerid]");
    if(!
IsPlayerConnected(userid))return SendClientMessage(pid,-1,"Player isn't connected!");
    if(
PlayerIsTargetedBy[userid]!=-1)return SendClientMessage(pid,-1,"Player is already kidnapped!");
    
PlayerIsTargetedBy[userid]=pid;
    
SendClientMessage(playerid,-1,"You kidnapped player!");
    
SendClientMessage(userid,-1,"You are kidnapped by player!");
    return 
1;
}
public 
OnPlayerEnterRaceCheckpoint(playerid){ 
    new 
id=PlayerIsTargetedBy[playerid];
    if(
id!=-1){
        
SendClientMessage(id,-1,"Kidnapped player died.");
        
SetPlayerHealth(playerid,0.0);
        
PlayerIsTargetedBy[playerid]=-1;
    }
    return 
1

Reply
#7

You make me got alot of bugs! Anyway Why did you created a new faction? I've created a new already CompleteHit[playerid] so Everything is worked but when player enter a checkpoint other's players will dead not the kidnapping player why?

PHP код:
public OnPlayerEnterRaceCheckpoint(playerid)
{
    new 
targetid CompleteKidnap[playerid];
    if(
CompleteKidnap[playerid] == 1)
    {
        new 
string[256];
        new 
tName[MAX_PLAYER_NAME];
        
GetPlayerName(targetidtNamesizeof(tName));
        
SetPlayerHealth(targetid0.0);
        
GivePlayerMoney(playeridMoney[playerid]);
        
format(stringsizeof(string), "{0BEA00}[Kidnapping]: {FFFFFF}Player {FF9F00}%s(%d) {FFFFFF}has dead by the {E33667}Kidnapping {FFFFFF}by user {FF9F00}%s(%d){FFFFFF}."tName,targetidPlayerName(playerid), playerid);
        
SendClientMessageToAll(-1string);
        
format(stringsizeof(string), "{0BEA00}[Money]:{FFFFFF} You have killed {FF9F00}%s(%d) {FFFFFF}by the {E33667}Kidnapping {FFFFFF}and you {E33667}Received{FFFFFF}:{0BEA00}$%d{FFFFFF}."TargetName(targetid),targetidMoney[playerid]);
        
SendClientMessage(playerid, -1string);
        
CompleteKidnap[playerid] = -1;
        
DisablePlayerRaceCheckpoint(playerid);
        
GameTextForPlayer(targetid"~N~~N~~R~DEAD BY THE ~Y~KIDNAPPING~R~.."5000 5);
        
GameTextForPlayer(playerid"~N~~N~~G~COMPLETED~R~.."5000 5);
    }
    return 
1;

Reply
#8

so how to fix it?
Reply
#9

Nevermind, delete this, didn't read the full issue.
Reply
#10

So how to fix it? Example: If the player has kidnapped the enemy player and when the player In the checkpoint the enemy player must be dead! how
Reply
#11

Quote:
Originally Posted by Man43
View Post
So how to fix it? Example: If the player has kidnapped the enemy player and when the player In the checkpoint the enemy player must be dead! how
Where the player enters the checkpoint, in there where it checks the PlayerIsTargetedBy, it needs to be the opposite.





You need to loop all players, checking if they are the target, and check the value of that against the playerid.


if PlayerIsTargetedBy[i]=playerid;


-Edit- You will also want to check if the kidnapped player is indeed with the kidnapper!!!! ----


then kill i.



What codestyle has put up is quite nice code for structure and such, you would be advised to keep messing with it, and read over it a bit to understand it more.


Reading good code is a good way to see good techniques and get more familiar with the language and such.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)