random pos for NPC -
ancezas - 03.12.2013
Hi, i want to create that the npc's will randomly change they position every hour, i have 4 npc's for that script, and i whant to add variable to them when they change they position, so every positinion need to have they variable, how to do that?
BTW i have this code without variable's:
pawn Код:
public:: Valanda( playerid )
{
new Float:DyleriuSpawn[][4] =
{
{ 308.1694, -192.6254, 1.5781, 283.7243 },
{ 254.7924, -158.8666, 1.5703, 29.9453 },
{ 243.6889, -297.9287, 1.5781, 335.6656 },
{ 206.9716, -102.9836, 4.8965, 89.1658 },
{ 309.9570, 45.7836, 2.8272, 258.9941 },
{ 644.3600, -511.2609, 16.3359, 8.0116 },
{ 704.5399, -612.6599, 16.3359, 9.2649 },
{ 819.0970, -562.1505, 16.3359, 176.8763 },
{ 1254.4191, 241.4952, 19.5547, 13.9415 },
{ 1242.1256, 212.1650, 19.5547, 85.0688 },
{ 1310.7725, 165.4595, 20.4609, 205.8482 },
{ 1317.1860, 213.5444, 19.5547, 190.6865 },
{ 1337.3336, 203.7981, 19.5547, 174.0563 },
{ 2314.8311, 53.3478, 26.4812, 306.5975 },
{ 2259.4260, 64.7797, 26.4844, 249.5937 },
{ -2176.0603, -2421.4243, 30.6250, 201.1717 },
{ -2114.4004, -2422.6992, 30.6250, 124.1144 },
{ -2071.6045, -2565.0767, 30.6301, 14.9284 }
};
new npcname[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, npcname, sizeof( npcname ) );
new rand = random( sizeof( DyleriuSpawn ) );
if( !strcmp( npcname, "Dyleris1", true ) )// Stumdo dumus
{
SetPlayerPos( playerid, DyleriuSpawn[ rand ][ 0 ], DyleriuSpawn[ rand ][ 1 ], DyleriuSpawn[ rand ][ 2 ] );
SetPlayerFacingAngle( playerid, DyleriuSpawn[ rand ][ 3 ] );
}
if( !strcmp( npcname, "Dyleris2", true ) )// Dumai, extazy
{
SetPlayerPos( playerid, DyleriuSpawn[ rand ][ 0 ], DyleriuSpawn[ rand ][ 1 ], DyleriuSpawn[ rand ][ 2 ] );
SetPlayerFacingAngle( playerid, DyleriuSpawn[ rand ][ 3 ] );
}
if( !strcmp( npcname, "Dyleris3", true ) )// LSD
{
SetPlayerPos( playerid, DyleriuSpawn[ rand ][ 0 ], DyleriuSpawn[ rand ][ 1 ], DyleriuSpawn[ rand ][ 2 ] );
SetPlayerFacingAngle( playerid, DyleriuSpawn[ rand ][ 3 ] );
}
if( !strcmp( npcname, "Dyleris4", true ) )//Visko
{
SetPlayerPos( playerid, DyleriuSpawn[ rand ][ 0 ], DyleriuSpawn[ rand ][ 1 ], DyleriuSpawn[ rand ][ 2 ] );
SetPlayerFacingAngle( playerid, DyleriuSpawn[ rand ][ 3 ] );
}
return true;
}
pawn Код:
SetTimer( "Valanda", 1000, true );
Re: random pos for NPC -
Scrillex - 03.12.2013
For example use gettime..
Basically it is saving the time when you are using it and you can set it after each reset. (but remember once in a week to rr your server)
PlayerInfo[playerid][pCMDT] = 3600
pawn Код:
forward GlobalCheck();
public GlobalCheck()
{
foreach(Player,i)
{
if(PlayerInfo[i][pCMDT] > 0)
if(--PlayerInfo[i][pCMDT] < 1)
{
PlayerInfo[i][pCMDT] = 0;
SendClientMessage(i,0xFFFFFFFF,"NPC is switching coords..");
}
}
return 1;
}
+ you will need new npcrandom
coords1,
cords2,
coords3
;
I think it could work but not sure.
In that case use.. gettime or use timer.. Two things what you can use..
Re: random pos for NPC -
ancezas - 03.12.2013
but my code isi't working with npc bots like i wrote it
Re: random pos for NPC -
ancezas - 03.12.2013
Okay i might solve this situation but there is huge bug, i have this code:
pawn Код:
public:: Valanda( playerid )
{
new Float:DyleriuSpawn1[ ][ 4 ] =
{
{ 254.7924,-158.8666,1.5703,29.9453 },
{ 644.3600,-511.2609,16.3359,8.0116 },
{ 1310.7725,165.4595,20.4609,205.8482 },
{ 2259.4260,64.7797,26.4844,49.5937 }
};
new Float:DyleriuSpawn2[ ][ 4 ] =
{
{ 243.6889,-297.9287,1.5781,335.6656 },
{ 704.5399,-612.6599,16.3359,9.2649 },
{ 1317.1860,213.5444,19.5547,190.6865 },
{ -2176.0603,-2421.4243,30.6250,201.1717 }
};
new Float:DyleriuSpawn3[ ][ 4 ] =
{
{ 206.9716,-102.9836,4.8965,89.1658 },
{ 819.0970,-562.1505,16.3359,176.8763 },
{ 1337.3336,203.7981,19.5547,174.0563 },
{ -2114.4004,-2422.6992,30.6250,124.1144 }
};
new Float:DyleriuSpawn4[ ][ 4 ] =
{
{ 309.9570,45.7836,2.8272,258.9941 },
{ 1242.1256,212.1650,19.5547,85.0688 },
{ 2314.8311,53.3478,26.4812,306.5975 },
{ -2071.6045,-2565.0767,30.6301,14.9284 }
};
new npcname[ MAX_PLAYER_NAME ];
GetPlayerName( playerid, npcname, sizeof( npcname ) );
new rand1 = random( sizeof( DyleriuSpawn1 ) );
new rand2 = random( sizeof( DyleriuSpawn2 ) );
new rand3 = random( sizeof( DyleriuSpawn3 ) );
new rand4 = random( sizeof( DyleriuSpawn4 ) );
if( !strcmp( npcname, "Dyleris1", true ) )// Stumdo dumus
{
SetPlayerPos( playerid, DyleriuSpawn1[ rand1 ][ 0 ],DyleriuSpawn1[ rand1 ][ 1 ],DyleriuSpawn1[ rand1 ][ 2 ] );
SetPlayerFacingAngle( playerid, DyleriuSpawn1[ rand1 ][ 3 ] );
}
if( !strcmp( npcname, "Dyleris2", true ) )// Dumai, extazy
{
SetPlayerPos( playerid, DyleriuSpawn2[ rand2 ][ 0 ],DyleriuSpawn2[ rand2 ][ 1 ],DyleriuSpawn2[ rand2 ][ 2 ] );
SetPlayerFacingAngle( playerid, DyleriuSpawn2[ rand2 ][ 3 ] );
}
if( !strcmp( npcname, "Dyleris3", true ) )// LSD
{
SetPlayerPos( playerid, DyleriuSpawn3[ rand3 ][ 0 ],DyleriuSpawn3[ rand3 ][ 1 ],DyleriuSpawn3[ rand3 ][ 2 ] );
SetPlayerFacingAngle( playerid, DyleriuSpawn3[ rand3 ][ 3 ] );
}
if( !strcmp( npcname, "Dyleris4", true ) )//Visko
{
SetPlayerPos( playerid, DyleriuSpawn4[ rand4 ][ 0 ],DyleriuSpawn4[ rand4 ][ 1 ],DyleriuSpawn4[ rand4 ][ 2 ] );
SetPlayerFacingAngle( playerid, DyleriuSpawn4[ rand4 ][ 3 ] );
}
return true;
}
but only the first one bot whose first connect's the server is changing his position, others just standing in spawn position, how to solve that?
Re: random pos for NPC -
ancezas - 04.12.2013
help please