/drag seems pretty easy
just do a new variable at top of the script
pawn Код:
new swatcar[MAX_PLAYERS];
Then, inside OnPlayerExitVehicle, just do something like this:
pawn Код:
if(gTeam[playerid] == TEAM_SWAT)
{
swatcar[playerid] = vehicleid;
}
NEEDED FUNCTIONS FOR ADVANCED /drag (put at bottom of script, needs strtok too !) :
pawn Код:
stock PlayerToPoint(Float:radi, playerid, Float:x, Float:y, Float:z)
{
new Float:oldposx, Float:oldposy, Float:oldposz;
new Float:tempposx, Float:tempposy, Float:tempposz;
GetPlayerPos(playerid, oldposx, oldposy, oldposz);
tempposx = (oldposx -x);
tempposy = (oldposy -y);
tempposz = (oldposz -z);
if (((tempposx < radi) && (tempposx > -radi)) && ((tempposy < radi) && (tempposy > -radi)) && ((tempposz < radi) && (tempposz > -radi)))
{
return 1;
}
return 0;
}
NEEDED FUNCTIONS FOR NORMAL /drag :
pawn Код:
stock strtok(const string[], &index,seperator=' ')
{
new length = strlen(string);
new offset = index;
new result[128];
while ((index < length) && (string[index] != seperator) && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
if ((index < length) && (string[index] == seperator))
{
index++;
}
return result;
}
NORMAL /drag :
pawn Код:
if(strcmp(cmdtext,"/drag",true) == 0) if(gTeam[playerid] == TEAM_SWAT)
{
new tmp[256];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /drag (playerid)");
new giveplayerid = strval(tmp);
if(IsPlayerConnected(giveplayerid))
{
new string[128];
new player[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
GetPlayerName(playerid,player,sizeof(player));
GetPlayerName(giveplayerid,giveplayer,sizeof(giveplayer));
format(string,128,"[ ! ] You have been dragged into %s's car !",player);
SendClientMessage(giveplayerid,COLOR_RED,string);
format(string,128,"[ ! ] You have dragged %s into your old vehicle !",giveplayer);
SendClientMessage(giveplayerid,COLOR_GREEN,string);
PutPlayerInVehicle(giveplayerid,swatvehicle[playerid],1);
return 1;
}
return 1;
}
ADVANCED /drag :
pawn Код:
if(strcmp(cmdtext,"/drag",true) == 0) if(gTeam[playerid] == TEAM_SWAT)
{
new tmp[256];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid,COLOR_WHITE,"USAGE: /drag (playerid)");
new giveplayerid = strval(tmp);
if(IsPlayerConnected(giveplayerid))
{
new xs[6];
GetVehiclePos(swatvehicle[playerid],xs[0],xs[1],xs[2]);
GetPlayerPos(giveplayerid,xs[3],xs[4],xs[5]);
if(!PlayerToPoint(20.0, playerid, xs[0], xs[1], xs[2])) return SendClientMessage(playerid,COLOR_RED,"[ ! ] You are not close enough to your vehicle !");
if(!PlayerToPoint(20.0, playerid, xs[3], xs[4], xs[5])) return SendClientMessage(playerid,COLOR_RED,"[ ! ] You are not close enough to the player !");
new string[128];
new player[MAX_PLAYER_NAME];
new giveplayer[MAX_PLAYER_NAME];
GetPlayerName(playerid,player,sizeof(player));
GetPlayerName(giveplayerid,giveplayer,sizeof(giveplayer));
format(string,128,"[ ! ] You have been dragged into %s's car !",player);
SendClientMessage(giveplayerid,COLOR_RED,string);
format(string,128,"[ ! ] You have dragged %s into your old vehicle !",giveplayer);
SendClientMessage(giveplayerid,COLOR_GREEN,string);
PutPlayerInVehicle(giveplayerid,swatvehicle[playerid],1);
return 1;
}
return 1;
}
You will need to modify some things...