Big Help Needed! -
fie - 31.08.2010
Hi guys, i have been trying to script this for along time but i just cant
so can you help?
Basically i want random spawn
but not just random spawn
This is just gamemode that is going to be an event
so i want it to freeze the player and random spawn them in sultans.
Is it possible you could script this for me and but it in a reply, that would be a really big help!
Thanks
Re: Big Help Needed! -
Paladin - 31.08.2010
pawn Код:
new Var[2]; // New Variable that checks the vehicle ID
new VarTaken[2]; // New Variable that checks what player is in the car
public OnGameModeInit()
{
VarTaken[0] = 552;
VarTaken[1] = 552;
Var[0] = CreateVehicle(VEHICLE INFO) // Spawn Vehicle 1
Var[1] = CreateVehicle(VEHICLE INFO) // Spawn Vehicle 2
return 1;
}
public OnPlayerDisconnect(playerid, reason) // If player disconnects from server
{
for(new v = 0; v < 1; v ++) // Calculates all vehicle variables
{
if(VarTaken[v] == playerid) // Checks if any player was assigned to that cars variable
{
VarTaken[v] = 552; // If they were, it sets the variable to 552, which means none
return 1;
}
}
return 1;
}
public OnPlayerSpawn(playerid) // On Player Spawn to set them in vehicle
{
if(VarTaken[0] == 552) // Checks if Vehicle 1 is taken
{
PutPlayerInVehicle(playerid, Var[0], 0);
VarTaken[0] = playerid;
}
else if(VarTaken[1] == 552) // If vehicle 1 is taken, it checks if vehicle 2 is taken
{
PutPlayerInVehicle(playerid, Var[1], 0);
VarTaken[1] = playerid;
}
else // If all vehicles are taken, it goes to the else
{
// There is no space for another player
return 1;
}
return 1;
}
Re: Big Help Needed! -
gamer931215 - 31.08.2010
Quote:
Originally Posted by Paladin
pawn Код:
new Var[2]; // New Variable that checks the vehicle ID new VarTaken[2]; // New Variable that checks what player is in the car
public OnGameModeInit() { VarTaken[0] = 552; VarTaken[1] = 552; Var[0] = CreateVehicle(VEHICLE INFO) // Spawn Vehicle 1 Var[1] = CreateVehicle(VEHICLE INFO) // Spawn Vehicle 2 return 1; } public OnPlayerDisconnect(playerid, reason) // If player disconnects from server { for(new v = 0; v < 1; v ++) // Calculates all vehicle variables { if(VarTaken[v] == playerid) // Checks if any player was assigned to that cars variable { VarTaken[v] = 552; // If they were, it sets the variable to 552, which means none return 1; } } return 1; }
public OnPlayerSpawn(playerid) // On Player Spawn to set them in vehicle { if(VarTaken[0] == 552) // Checks if Vehicle 1 is taken { PutPlayerInVehicle(playerid, Var[0], 0); VarTaken[0] = playerid; } else if(VarTaken[1] == 552) // If vehicle 1 is taken, it checks if vehicle 2 is taken { PutPlayerInVehicle(playerid, Var[1], 0); VarTaken[1] = playerid; } else // If all vehicles are taken, it goes to the else { // There is no space for another player return 1; } return 1; }
|
wtf lol, that is hard to understand with all those variables... i made one once a time for an friend a lot simpler, he had an derby gamemode but too bad i lost the source
Anyways if it doesnt work for you check out the standard GrandLarc gamemode, It has random spawnpoints so you can see how it works. Then you can easily putting them in a vehicle with PutPlayerInVehicle (
https://sampwiki.blast.hk/wiki/PutPlayerInVehicle)
Re: Big Help Needed! -
Paladin - 31.08.2010
Quote:
Originally Posted by gamer931215
too bad i lost the source
|
Sure you did.
If you can't supply anything else that works, please stfu.
Re: Big Help Needed! -
gamer931215 - 31.08.2010
Quote:
Originally Posted by Paladin
Sure you did.
If you can't supply anything else that works, please stfu.
|
Dont start an fight, no offence but your code is pretty advanced to understand, even i didnt.
I gave the guy also the tip if that doesnt work to look at grandlarc, thats where i got it from how to make it.
And YES i really lost it, its just an mini gamemode for an friend so why shall i keep it then ?
And again, dont insult directly
Re: Big Help Needed! -
Paladin - 31.08.2010
the code that I scripted there, is pretty elementary if you have good logic skills, if he does not understand a thing that I wrote, he should be using the WIKI to understand functions, as that is what is required to fully understand it, which anyone who even thinks of posting here should actually have read before hand to understand the concept?
Re: Big Help Needed! -
gamer931215 - 31.08.2010
Quote:
Originally Posted by Paladin
the code that I scripted there, is pretty elementary if you have good logic skills, if he does not understand a thing that I wrote, he should be using the WIKI to understand functions, as that is what is required to fully understand it, which anyone who even thinks of posting here should actually have read before hand to understand the concept?
|
If someone asks for help, i think you should give the simpliest code to do it. Its not only "fixing" the problem, they should also learn to do it thereself! And i think
pawn Код:
new Float:gRandomPlayerSpawns[4][3] = { //[4] = total spawnpoints, 3 is variables (x,y,z so 3)
{1958.3783,1343.1572,15.3746},
{2199.6531,1393.3678,10.8203},
{2483.5977,1222.0825,10.8203},
{2637.2712,1129.2743,11.1797}
};
public OnPlayerSpawn(playerid)
{
new rand = random(sizeof(gRandomPlayerSpawns)); //getting one of the positions (randomized)
SetPlayerPos(playerid, gRandomPlayerSpawns[rand][0], gRandomPlayerSpawns[rand][1], gRandomPlayerSpawns[rand][2]); //setting random pos
= AddStaticVehicle(vehicle id etc...); //creating vehicle and saving it in veh
PutPlayerInVehicle(playerid,veh,0); //putting player in vehicle
}
is easyer to understand with basic scripting, then using more advanced things like pvar's...
Re: Big Help Needed! -
Paladin - 31.08.2010
My Script offers more.
Re: Big Help Needed! -
gamer931215 - 31.08.2010
Quote:
Originally Posted by Paladin
My Script offers more.
|
True, but he didnt ask for all that... i think he just needs an simple method of random spawnpoints and putting them into vehicles like he requested.
Re: Big Help Needed! -
Crusher!! - 31.08.2010
To many things for to easy script
pawn Код:
#include <a_samp>
#define VEHICLE_MODEL 522 // its now NRG, don't know whats sultan ID.
new veh[MAX_PLAYERS];
new Float: Spawns[4][4] =
{
// {x, y, z, rotation}
{1958.3783, 1343.1572, 15.3746, 0.0},
{2199.6531, 1393.3678, 10.8203, 0.0},
{2483.5977, 1222.0825, 10.8203, 0.0},
{2637.2712, 1129.2743, 11.1797, 0.0}
};
//------------------------------------------------------------------------------
public OnPlayerDisconnect(playerid, reason)
{
DestroyVehicle(veh[playerid]);
return 1;
}
public OnPlayerSpawn(playerid)
{
new Rand = random(sizeof(Spawns));
SpawnPlayerInVehicle(playerid,VEHICLE_MODEL,Spawns[Rand][0],Spawns[Rand][1],Spawns[Rand][2],Spawns[Rand][3],veh[playerid]);
return 1;
}
public OnPlayerExitVehicle(playerid,vehicleid)
{
DestroyVehicle(veh[playerid]);
SetPlayerHealth(playerid,0);
return 1;
}
//------------------------------------------------------------------------------
stock SpawnPlayerInVehicle(pid,model,Float:x,Float:y,Float:z,Float:r, &var) // Crush3r
{
SetPlayerPos(pid,x,y,z);
var = CreateVehicle(model,x,y,z,r,0,0,-1);
PutPlayerInVehicle(pid,var,0);
return var;
}
Pastebin?:
http://pastebin.com/4QhiBGem