Where to place this code?
#1

Код:
forward SetPlayerRandomCopSpawn(playerid); // Forwarding the function
public SetPlayerRandomCopSpawn(playerid) // Setting it up
{
    new rand = random(sizeof(attackerSpawns)); // Making it select random options instead of a definite one
    SetPlayerPos(playerid, attackerSpawns[rand][0], attackerSpawns[rand][1], attackerSpawns[rand][2], attackerSpawns[rand][3], attackerSpawns[rand][4], attackerSpawns[rand][5]); 
    return 1;
}

forward SetPlayerRandomCriminalSpawn(playerid);
public SetPlayerRandomCriminalSpawn(playerid)
{
    new rand = random(sizeof(defenderSpawns));
    SetPlayerPos(playerid, defenderSpawns[rand][0], defenderSpawns[rand][1], defenderSpawns[rand][2], defenderSpawns[rand][3], defenderSpawns[rand][4], defenderSpawns[rand][5]); 
    return 1;
}
Got everything defined already, I only have to put this somewhere now, but I don't know where.

EDIT: was told to put this out of all callbacks, I really don't know where, any help? D:
Reply
#2

actually i dnt know where but try it on gm.
Reply
#3

Quote:
Originally Posted by shaniyal
Посмотреть сообщение
actually i dnt know where but try it on gm.
Do you genuinely think I didn't try that?
Reply
#4

Inside of your gamemode, outside of any of callbacks.
Reply
#5

Quote:
Originally Posted by C00K13M0N$73R
Посмотреть сообщение
Inside of your gamemode, outside of any of callbacks.
I tried putting it after public OnGamemodeExit, got this error:

Код:
C:\Users\Mijn pc\Desktop\Script Tester\gamemodes\TDM2.pwn(57) : error 032: array index out of bounds (variable "attackerSpawns")
C:\Users\Mijn pc\Desktop\Script Tester\gamemodes\TDM2.pwn(62) : warning 235: public function lacks forward declaration (symbol "SetPlayerRandomDefenderSpawn")
C:\Users\Mijn pc\Desktop\Script Tester\gamemodes\TDM2.pwn(65) : error 032: array index out of bounds (variable "defenderSpawns")
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Errors.
Reply
#6

Fixed it, I'm such an idiot. I mistook the defenderSpawns[rand][x]);'s for allowing certain spawn points to be enabled, although [rand] tag means random, [0] = X, [1] = Y, [2] = Z. Sorry for wasting your time D:
Reply
#7

pawn Код:
forward SetPlayerRandomCopSpawn(playerid); // Forwarding the function
public SetPlayerRandomCopSpawn(playerid) // Setting it up
{
    new rand = random(sizeof(attackerSpawns)); // Making it select random options instead of a definite one
    SetPlayerPos(playerid, attackerSpawns[rand][0], attackerSpawns[rand][1], attackerSpawns[rand][2]);
    return 1;
}

forward SetPlayerRandomCriminalSpawn(playerid);
public SetPlayerRandomCriminalSpawn(playerid)
{
    new rand = random(sizeof(defenderSpawns));
    SetPlayerPos(playerid, defenderSpawns[rand][0], defenderSpawns[rand][1], defenderSpawns[rand][2]);
    return 1;
}
As far as im aware, SetPlayerPos only have 4 parameters, (playerid,Float,Float:y,Float:z)

You were using 6.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)