Random Checkpoints help - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Random Checkpoints help (
/showthread.php?tid=474984)
Random Checkpoints help -
EthanMason - 10.11.2013
Hello Guys, i've started working on A pizza job Filterscript but i faced some problems! Hope you'd be able to help me out with this ! So this is the Part of the script i'm facing prob with
Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
{
new rand = random(2),Float:X, Float:Y, Float:Z;
switch (rand)
{
case 0:{X = 2332.1140;Y = -1680.7076;Z = 13.7506;}
case 1:{X = 2508.3562;Y = -1654.8031;Z = 13.8660;}
case 2:{X = 2141.2703;Y = -1611.0664;Z = 13.8660;}
case 3:{X = 1092.9705;Y = -1093.6687;Z = 25.5253;}
SetPlayerCheckpoint(playerid, X, Y, Z, 5.0);
SendClientMessage(playerid, -1," Drive the pizza bike to the checkpoint then bring back the bike!");
}
}
}
i got this Warnings and errors
Код:
C:\Users\dell\Desktop\Coffre\SAMP Freedom Gaming\filterscripts\ethanpizza.pwn(98) : warning 215: expression has no effect
C:\Users\dell\Desktop\Coffre\SAMP Freedom Gaming\filterscripts\ethanpizza.pwn(97) : warning 204: symbol is assigned a value that is never used: "Z"
C:\Users\dell\Desktop\Coffre\SAMP Freedom Gaming\filterscripts\ethanpizza.pwn(97) : warning 204: symbol is assigned a value that is never used: "Y"
C:\Users\dell\Desktop\Coffre\SAMP Freedom Gaming\filterscripts\ethanpizza.pwn(97) : warning 204: symbol is assigned a value that is never used: "X"
C:\Users\dell\Desktop\Coffre\SAMP Freedom Gaming\filterscripts\ethanpizza.pwn(97 -- 102) : error 054: unmatched closing brace ("}")
Thanks in advance!
Re: Random Checkpoints help -
EiresJason - 10.11.2013
pawn Код:
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
{
new rand,Float:X, Float:Y, Float:Z;
rand = random(4);
switch(rand)
{
case 0:{X = 2332.1140;Y = -1680.7076;Z = 13.7506;}
case 1:{X = 2508.3562;Y = -1654.8031;Z = 13.8660;}
case 2:{X = 2141.2703;Y = -1611.0664;Z = 13.8660;}
case 3:{X = 1092.9705;Y = -1093.6687;Z = 25.5253;}
}
SetPlayerCheckpoint(playerid, X, Y, Z, 5.0);
SendClientMessage(playerid, -1," Drive the pizza bike to the checkpoint then bring back the bike!");
}
}
Re: Random Checkpoints help -
Loot - 10.11.2013
A better code in my opinion would be:
pawn Код:
// top of the script
#define MAX_CHECKPOINTS (3)
static Float: checkpointLocations[MAX_CHECKPOINTS][3] =
{
{ 2332.1140, -1680.7076, 13.7506 },
{ 2508.3562, -1654.8031, 13.8660 },
{ 2141.2703, -1611.0664, 13.8660 },
{ 1092.9705, -1093.6687, 25.5253 }
};
public OnPlayerEnterVehicle(playerid, vehicleid, ispassenger)
{
if(GetVehicleModel(GetPlayerVehicleID(playerid)) == 448)
{
new rand = random(MAX_CHECKPOINTS);
SetPlayerCheckpoint(playerid, checkpointLocations[rand][0], checkpointLocations[rand][1], checkpointLocations[rand][2], 5.0);
SendClientMessage(playerid, -1," Drive the pizza bike to the checkpoint then bring back the bike!");
}
}