
Originally Posted by
creighton
Attempted to get the task_combat working against online players, here's what I tried:
Code:
for (player = 0; player <= ONLINEPLAYERS; player++){
DebugBreak("500");
if(DOES_CHAR_EXIST(zombies[i]) && DOES_CHAR_EXIST(players[player].ped)){
int tehzombie;
DebugBreak("501");GET_NETWORK_ID_FROM_PED(zombies[i], &tehzombie);
DebugBreak("502");SET_NETWORK_ID_CAN_MIGRATE(tehzombie, true);
DebugBreak("503");REQUEST_CONTROL_OF_NETWORK_ID(tehzombie);
while(!HAS_CONTROL_OF_NETWORK_ID(tehzombie)){
tick++;
DebugBreak("504");REQUEST_CONTROL_OF_NETWORK_ID(tehzombie);
if(tick >= 250){
//unable to communicate with zombie
DebugBreak("505");continue;
}
DebugBreak("506");WAIT(0);
}
DebugBreak("507");TASK_COMBAT(zombies[i], players[player].ped);
}
}
I didn't see any change.
are you trying to get net id from ped or zombie?
I know of a way but it caused lag .. the idea: check everyone in the lobby every 20/30 sec and compare distance then when close enough "sense range" and use task combat.. I don't think its necessary to get the net ids
but to have it check everyone in the room and then have it compare distances! seems like a good idea for pc
Code:
+
Ped GetOnlinePed(uint pnumber){
Ped playerped = INVALID_HANDLE;
if(IS_NETWORK_PLAYER_ACTIVE(CONVERT_INT_TO_PLAYERINDEX(pnumber))){
if(!HAS_NETWORK_PLAYER_LEFT_GAME(CONVERT_INT_TO_PLAYERINDEX(pnumber))){
GET_PLAYER_CHAR(CONVERT_INT_TO_PLAYERINDEX(pnumber), &playerped);
if(DOES_CHAR_EXIST(playerped)){
return playerped;
}
}
}
}
if(IS_NETWORK_SESSION()){
int i;
for (i = 0; i < ZOMB_MAX; i++){
if ( DOES_CHAR_EXIST(zombies[i]) ){
int onlinePed;
float px,py,pz,zx,zy,zz,zombSence;
for (onlinePed = 0; onlinePed < GET_NUMBER_OF_PLAYERS(); onlinePed++){
GET_CHAR_COORDINATES(GetOnlinePed(onlinePed), &px,&py,&pz);
GET_CHAR_COORDINATES(zombies[i], &zx,&zy,&zz);
GET_DISTANCE_BETWEEN_COORDS_3D(px,py,pz,zx,zy,zz, &zombSence);
if ((zombSence < 22.0) && (GetOnlinePed(onlinePed) != GetPlayerPed())){
TASK_COMBAT(zombies[i],GetOnlinePed(onlinePed));
continue;
}
}
}
}
}
there was also random freezing. Im not exactly awesome at C!