stock LoadEntrances()
{
new File:file = fopen("entrances.cfg",io_read);
if(file)
{
new
line[512],
parts[16][32],
commentpos = -1,
count
;
for(new i = 0;i < sizeof(Entrances);i++)
{
if(EntranceRef[i][0]) DestroyPickup(EntranceRef[i][0]);
if(EntranceRef[i][1]) DestroyPickup(EntranceRef[i][1]);
Entrances[i][outside_icon] = 0;
Entrances[i][outside_x] = 0;
Entrances[i][outside_y] = 0;
Entrances[i][outside_z] = 0;
Entrances[i][outside_a] = 0;
Entrances[i][outside_i] = 0;
Entrances[i][outside_w] = 0;
Entrances[i][inside_icon] = 0;
Entrances[i][inside_x] = 0;
Entrances[i][inside_y] = 0;
Entrances[i][inside_z] = 0;
Entrances[i][inside_a] = 0;
Entrances[i][inside_i] = 0;
Entrances[i][inside_w] = 0;
}
while(fread(file,line) && count < sizeof(Entrances))
{
commentpos = strfind(line,"//",true);
if(commentpos != 0)
{
if(commentpos != -1) strmid(line,line,0,commentpos);
split(line,parts,',');
Entrances[count][outside_icon] = strval(parts[0]);
Entrances[count][outside_x] = floatstr(parts[1]);
Entrances[count][outside_y] = floatstr(parts[2]);
Entrances[count][outside_z] = floatstr(parts[3]);
Entrances[count][outside_a] = floatstr(parts[4]);
Entrances[count][outside_i] = strval(parts[5]);
Entrances[count][outside_w] = strval(parts[6]);
Entrances[count][inside_icon] = strval(parts[7]);
Entrances[count][inside_x] = floatstr(parts[8]);
Entrances[count][inside_y] = floatstr(parts[9]);
Entrances[count][inside_z] = floatstr(parts[10]);
Entrances[count][inside_a] = floatstr(parts[11]);
Entrances[count][inside_i] = strval(parts[12]);
Entrances[count][inside_w] = strval(parts[13]);
EntranceRef[count][0] = CreatePickup(
Entrances[count][outside_icon],
23,
Entrances[count][outside_x],
Entrances[count][outside_y],
Entrances[count][outside_z],
Entrances[count][outside_w]
);
EntranceRef[count][1] = CreatePickup(
Entrances[count][inside_icon],
23,
Entrances[count][inside_x],
Entrances[count][inside_y],
Entrances[count][inside_z],
Entrances[count][inside_w]
);
count++;
}
}
return 1;
}
return 0;
}
enum entrancestats { outside_icon , Float:outside_x , Float:outside_y , Float:outside_z , Float:outside_a , outside_i , outside_w , inside_icon , Float:inside_x , Float:inside_y , Float:inside_z , Float:inside_a , inside_i , inside_w , opens , closes }
new Entrances[100][entrancestats];
new EntranceRef[sizeof(Entrances)][2];
LoadEntrances();
1239, 1554.690551, -1675.809082, 16.195312, 0.00, 0, 0, 1239, 246.321929, 108.295661, 1003.218750, 0.00, 10, 0 //SAPD
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/door", true) == 0)
{
return 1;
}
return 0;
}
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][outside_w]
)
{
SetPlayerPos(playerid,Entrances[i][inside_x],Entrances[i][inside_y],Entrances[i][inside_z]);
SetPlayerFacingAngle(playerid,Entrances[i][inside_a]);
SetPlayerInterior(playerid,Entrances[i][inside_i]);
SetPlayerVirtualWorld(playerid,Entrances[i][inside_w]);
SetCameraBehindPlayer(playerid);
return 1;
}
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/door", true) == 0)
{
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][outside_w]
)
{
SetPlayerPos(playerid,Entrances[i][inside_x],Entrances[i][inside_y],Entrances[i][inside_z]);
SetPlayerFacingAngle(playerid,Entrances[i][inside_a]);
SetPlayerInterior(playerid,Entrances[i][inside_i]);
SetPlayerVirtualWorld(playerid,Entrances[i][inside_w]);
SetCameraBehindPlayer(playerid);
return 1;
}
}
return 1;
}
return 0;
}
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][inside_x],Entrances[i][inside_y],Entrances[i][inside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][inside_w]
)
{
SetPlayerPos(playerid,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z]);
SetPlayerFacingAngle(playerid,Entrances[i][outside_a]);
SetPlayerInterior(playerid,Entrances[i][outside_i]);
SetPlayerVirtualWorld(playerid,Entrances[i][outside_w]);
return 1;
}
}
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp(cmdtext, "/door", true) == 0)
{
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][outside_w]
)
{
SetPlayerPos(playerid,Entrances[i][inside_x],Entrances[i][inside_y],Entrances[i][inside_z]);
SetPlayerFacingAngle(playerid,Entrances[i][inside_a]);
SetPlayerInterior(playerid,Entrances[i][inside_i]);
SetPlayerVirtualWorld(playerid,Entrances[i][inside_w]);
SetCameraBehindPlayer(playerid);
return 1;
}
}
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][inside_x],Entrances[i][inside_y],Entrances[i][inside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][inside_w]
)
{
SetPlayerPos(playerid,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z]);
SetPlayerFacingAngle(playerid,Entrances[i][outside_a]);
SetPlayerInterior(playerid,Entrances[i][outside_i]);
SetPlayerVirtualWorld(playerid,Entrances[i][outside_w]);
return 1;
}
}
return 1;
}
return 0;
}
if(strcmp(cmdtext, "/reloade", true) == 0)
{
if(IsPlayerAdmin(playerid))
{
LoadEntrances();
SendClientMessage(playerid, -1, "Entrances reloaded!");
return 1;
}
}
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][outside_w]
)
{
GameTextForPlayer(playerid, "~w~Type ~r~/enter~w~ to go inside", 5000, 5);
return 1;
}
}
public OnPlayerPickUpPickup(playerid, pickupid)
public OnPlayerPickUpPickup(playerid, pickupid)
{
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][outside_w]
)
{
GameTextForPlayer(playerid, "~w~Type ~r~/door~w~ to go inside", 5000, 5);
return 1;
}
}
return 1;
}
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][inside_x],Entrances[i][inside_y],Entrances[i][inside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][inside_w]
)
{
GameTextForPlayer(playerid, "~w~Type ~r~/door~w~ to go outside", 5000, 5);
return 1;
}
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][outside_w]
)
{
GameTextForPlayer(playerid, "~w~Type ~r~/door~w~ to go inside", 5000, 5);
return 1;
}
}
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][inside_x],Entrances[i][inside_y],Entrances[i][inside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][inside_w]
)
{
GameTextForPlayer(playerid, "~w~Type ~r~/door~w~ to go outside", 5000, 5);
return 1;
}
}
return 1;
}
stock split(const strsrc[], strdest[][], delimiter)
{
new i, li;
new aNum;
new len;
while(i <= strlen(strsrc)){
if(strsrc[i]==delimiter || i==strlen(strsrc)){
len = strmid(strdest[aNum], strsrc, li, i, 128);
strdest[aNum][len] = 0;
li = i+1;
aNum++;
}
i++;
}
return 1;
}
public OnPlayerPickUpPickup(playerid, pickupid)
{
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][outside_x],Entrances[i][outside_y],Entrances[i][outside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][outside_w]
)
{
GameTextForPlayer(playerid, "~w~Type ~r~/door~w~ to go inside", 5000, 5);
return 1;
}
}
for(new i = 0;i < sizeof(EntranceRef);i++)
{
if(
IsPlayerInRangeOfPoint(playerid,2,Entrances[i][inside_x],Entrances[i][inside_y],Entrances[i][inside_z])
&&
GetPlayerVirtualWorld(playerid) == Entrances[i][inside_w]
)
{
GameTextForPlayer(playerid, "~w~Type ~r~/door~w~ to go outside", 5000, 5);
return 1;
}
}
return 1;
}
Lol. I found the exact same thing in the SARP r112 script. Good job anyway.
|
Yeah that's where the LoadEntrances(); came from, but a lot of people done scripts for SARP r112 so I couldn't give who exactly did it credit, but I just made this tutorial to tell people how to use it :P
|
Shanks Wizzle/Smo Wang/Dion Slater.
Good job. Hell, I'm even using this! |