Help with this....
#1

Ok, I'm trying to make it so a Cop can type /follow [playerid] and the player wil follow the cop where ever he goes until hes /unfollowed then /uncuffed.

Here's my code so far

pawn Код:
if(strcmp(cmd, "/follow", true) == 0)
    if(gteam[playerid]==Team_LSPD || gteam[playerid] ==Team_SFPD || gteam[playerid] ==Team_LVPD || gteam[playerid] ==Team_SASP || gteam[playerid]==Team_FBI || gteam[playerid]==Team_DCP || gteam[playerid]==Team_Army || gteam[playerid]==Team_ArmyMed || gteam[playerid]==Team_GOV || IsPlayerAdmin(playerid) == 1) {

    new Float:x, Float:y, Float:z;
        new tmp[256];
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /follow [Player ID]");
            return 1;
        }
        giveplayerid = strval(tmp);
        {
        if (IsPlayerConnected(giveplayerid) && L1A[giveplayerid]!=1 ) {
        if( (GetDistanceBetweenPlayers(playerid,giveplayerid) < 500) && (IsPlayerInAnyVehicle(giveplayerid)==0) ){

            SetTimer("follow1",1000,1);
            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            SetCameraBehindPlayer(playerid);
            ResetPlayerWeapons(giveplayerid);
            TogglePlayerControllable(giveplayerid,0);
            TogglePlayerControllable(playerid,1);
            SetPlayerArmour(giveplayerid,0);
        }
        }
        }

        return 1;
    }


    if(strcmp(cmd, "/unfollow", true) == 0)
    if(gteam[playerid]==Team_LSPD || gteam[playerid] ==Team_SFPD || gteam[playerid] ==Team_LVPD || gteam[playerid] ==Team_SASP || gteam[playerid]==Team_FBI || gteam[playerid]==Team_DCP || gteam[playerid]==Team_Army || gteam[playerid]==Team_ArmyMed || gteam[playerid]==Team_GOV || IsPlayerAdmin(playerid) == 1) {

    new Float:x, Float:y, Float:z;
        new tmp[256];
        tmp = strtok(cmdtext, idx);

        if(!strlen(tmp)) {
            SendClientMessage(playerid, COLOR_WHITE, "USAGE: /follow [Player ID]");
            return 1;
        }
        giveplayerid = strval(tmp);
        {
        if (IsPlayerConnected(giveplayerid) && L1A[giveplayerid]!=1 ) {
        if( (GetDistanceBetweenPlayers(playerid,giveplayerid) < 20000000000000000) && (IsPlayerInAnyVehicle(giveplayerid)==0) ){

            GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
            GetPlayerName(playerid, sendername, sizeof(sendername));
            SetCameraBehindPlayer(playerid);
            ResetPlayerWeapons(giveplayerid);
            GetPlayerPos(playerid,x,y,z);
            GetPlayerPos(giveplayerid,x,y,z);
            SetPlayerPos(giveplayerid,x,y,z);
            SetPlayerPos(playerid,x,y,z);
            TogglePlayerControllable(giveplayerid,0);
            SetPlayerArmour(giveplayerid,0);

        }
        }
        }

        return 1;
    }



[PAWNO]
public follow1(playerid,giveplayerid)
{
new Float:pX,Float:pY,Float:pZ;

GetPlayerPos(playerid,pX,pY,pZ);
SetPlayerPos(giveplayerid,pX,pY,pZ+2);
SetPlayerInterior(playerid,GetPlayerInterior(giveplayerid));
return 1;
}
Any help is appreciated

EDIT: I am pput in the air i fail then im put u again and the player who i selected is thrown underground
Reply
#2

Steven82: didnt work
Reply
#3

If you fly in air then you failed to set the correct interior
add this to /follow command:

SetPlayerInterior(playerid,0);
Reply
#4

if(strcmp(cmd, "/follow", true) == 0)
if(gteam[playerid]==Team_LSPD || gteam[playerid] ==Team_SFPD || gteam[playerid] ==Team_LVPD || gteam[playerid] ==Team_SASP || gteam[playerid]==Team_FBI || gteam[playerid]==Team_DCP || gteam[playerid]==Team_Army || gteam[playerid]==Team_ArmyMed || gteam[playerid]==Team_GOV || IsPlayerAdmin(playerid) == 1) {

new Float, Float:y, Float:z;
new tmp[256];
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /follow [Player ID]");
return 1;
}
giveplayerid = strval(tmp);
{
if (IsPlayerConnected(giveplayerid) && L1A[giveplayerid]!=1 ) {
if( (GetDistanceBetweenPlayers(playerid,giveplayerid) < 500) && (IsPlayerInAnyVehicle(giveplayerid)==0) ){

SetTimer("follow1",1000,1);
GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
SetCameraBehindPlayer(playerid);
SetPlayerInterior(playerid,0);
ResetPlayerWeapons(giveplayerid);
TogglePlayerControllable(giveplayerid,0);
TogglePlayerControllable(playerid,1);
SetPlayerArmour(giveplayerid,0);
}
}
}

return 1;
}


if(strcmp(cmd, "/unfollow", true) == 0)
if(gteam[playerid]==Team_LSPD || gteam[playerid] ==Team_SFPD || gteam[playerid] ==Team_LVPD || gteam[playerid] ==Team_SASP || gteam[playerid]==Team_FBI || gteam[playerid]==Team_DCP || gteam[playerid]==Team_Army || gteam[playerid]==Team_ArmyMed || gteam[playerid]==Team_GOV || IsPlayerAdmin(playerid) == 1) {

new Float, Float:y, Float:z;
new tmp[256];
tmp = strtok(cmdtext, idx);

if(!strlen(tmp)) {
SendClientMessage(playerid, COLOR_WHITE, "USAGE: /follow [Player ID]");
return 1;
}
giveplayerid = strval(tmp);
{
if (IsPlayerConnected(giveplayerid) && L1A[giveplayerid]!=1 ) {
if( (GetDistanceBetweenPlayers(playerid,giveplayerid) < 20000000000000000) && (IsPlayerInAnyVehicle(giveplayerid)==0) ){

GetPlayerName(giveplayerid, giveplayer, sizeof(giveplayer));
GetPlayerName(playerid, sendername, sizeof(sendername));
SetCameraBehindPlayer(playerid);
ResetPlayerWeapons(giveplayerid);
GetPlayerPos(playerid,x,y,z);
GetPlayerPos(giveplayerid,x,y,z);
SetPlayerPos(giveplayerid,x,y,z);
SetPlayerPos(playerid,x,y,z);
TogglePlayerControllable(giveplayerid,0);
SetPlayerArmour(giveplayerid,0);

}
}
}

return 1;
}



[PAWNO]
public follow1(playerid,giveplayerid)
{
new FloatX,FloatY,FloatZ;

GetPlayerPos(playerid,pX,pY,pZ);
SetPlayerPos(giveplayerid,pX,pY,pZ+2);
SetPlayerInterior(playerid,GetPlayerInterior(givep layerid));
return 1;
}

Any help is appreciated
Reply
#5

Look up timers on the Wiki for a start dude, after that check out the optimisation thread by ******.
Reply


Forum Jump:


Users browsing this thread: