19.07.2010, 22:03
Hi.
I'm working on a Mini-mission like GM, to play with some friends, but, after timers don't working, various bugs/things fixed, etc, I can't solve the random players and car positions (MTA Grid/Adrenaline GM like)...
I do the random player select like I've do with other GM, but on the other GM this method works, on this GM not...
The player who's put on the hunter is always the ID 0.
I've tried to use the random with the for(new i=0; i<MAX_PLAYERS; i++) and tried with various ways, but doesn't work. It's always the ID 0.
Other problem is the random spawn (spawn on randomic position), but he needs to check if exist any player at the same coordinate. In the first time, the GM spawns too much cars, bugging/lagging the server and the game for players, but i've fixed using SetTimerEx and running for each player the check position. I get/set the random positions for the players/cars, and a fixed position for the hunter (where's created on the OnGameModeInit), but he doesn't check if someone stays at the same pos, he only spawns 2+ players at the same pos.
What's wrong with these codes?
If I can't fix in this way, I gonna try other way for the random cars. But I need to fix the random player on Hunter first, because this is the most important.
Thanks
(My english is horrible, but I think it's understandable)
I'm working on a Mini-mission like GM, to play with some friends, but, after timers don't working, various bugs/things fixed, etc, I can't solve the random players and car positions (MTA Grid/Adrenaline GM like)...
I do the random player select like I've do with other GM, but on the other GM this method works, on this GM not...
The player who's put on the hunter is always the ID 0.
Код:
public Time1() { new randompl = random(MAX_PLAYERS); PutPlayerInVehicle(randompl, hunter, 0); IsHunter[randompl] = 1; plhunter = randompl; SetVehicleHealth(hunter, 9999999999); printf("O ID Randomico eh %d", randompl); //Check if he generates the random ID for(new i=0; i<MAX_PLAYERS; i++) { if(IsPlayerConnected(i) && !IsHunter[i]) { carplayers[i] = SetTimerEx("CarPlayers", 1000, 1, "d", i); } } SetTimer("Time2", 20000, 0); }
Other problem is the random spawn (spawn on randomic position), but he needs to check if exist any player at the same coordinate. In the first time, the GM spawns too much cars, bugging/lagging the server and the game for players, but i've fixed using SetTimerEx and running for each player the check position. I get/set the random positions for the players/cars, and a fixed position for the hunter (where's created on the OnGameModeInit), but he doesn't check if someone stays at the same pos, he only spawns 2+ players at the same pos.
Код:
public CarPlayers(playerid) { new pname[24]; GetPlayerName(playerid, pname, sizeof(pname)); printf("Rodou CarPlayers para %s", pname); //Check if the timer runs for all players new rand; rand = random(sizeof(RandomSpawnCars)); if(!IsPlayerInRangeOfPoint(playerid, 3.0, RandomSpawnCars[rand][0], RandomSpawnCars[rand][1], RandomSpawnCars[rand][2]) && IsHunter[playerid] == 0) { SetPlayerPos(playerid, RandomSpawnCars[rand][0], RandomSpawnCars[rand][1], RandomSpawnCars[rand][2]); SetPlayerFacingAngle(playerid, RandomSpawnCars[rand][3]); SetTimerEx("PutPlayer",500,false,"d",playerid); return KillTimer(carplayers[playerid]); } else if(IsPlayerInRangeOfPoint(playerid, 3.0, RandomSpawnCars[rand][0], RandomSpawnCars[rand][1], RandomSpawnCars[rand][2]) && IsHunter[playerid] == 0) { return rand = random(sizeof(RandomSpawnCars)); } else if(IsPlayerInAnyVehicle(playerid) && !IsHunter[playerid]) { return KillTimer(carplayers[playerid]); } return 0; } public PutPlayer(playerid) { new Float:X, Float:Y, Float:Z, Float:A; GetPlayerPos(playerid, X, Y, Z); GetPlayerFacingAngle(playerid, A); new veh = CreateVehicle(475, X, Y, Z, A, -1, -1, 10); PutPlayerInVehicle(playerid, veh, 0); Fugitivo[playerid] = 1; KillTimer(carplayers[playerid]); return 1; }
If I can't fix in this way, I gonna try other way for the random cars. But I need to fix the random player on Hunter first, because this is the most important.
Thanks
(My english is horrible, but I think it's understandable)