Code: Show/Hide #define maxDrivers 6 typedef struct { Player *p; int active; int chkpt; int lap; int kills; float times[11]; } Driver; local Driver dvr[maxDrivers]; //Requires chat, pd and mainloop local void startRace() { int drivers=0, i; Link *link; Player *p; if (!pd) return; //Safety if (!chat) return; //Safety lm->Log(L_INFO, "<hio> Adding players to race:"); pd->Lock(); FOR_EACH_PLAYER(p) { //In starting area? if (!inArea(startBox, p)) { lm->Log(L_DRIVEL, "<hio> [%s] not in start box", p->name); // continue; } else //PM if not enough slots if (drivers >= maxDrivers) { lm->Log(L_DRIVEL, "<hio> [%s] race full", p->name); chat->SendMessage(p, "This race is full, sorry"); // continue; } else //Add to race for(i=0; i<maxDrivers; i++) { if (dvr[i].active == 0) { //== 1) continue; drivers++; dvr[i].active = 1; dvr[i].chkpt = 1; dvr[i].lap = 0; dvr[i].kills = 0; dvr[i].p = p; lm->Log(L_INFO, "<hio> [%s] added to race", p->name); chat->SendMessage(p, "Get ready to race..."); i = maxDrivers; //break; } } } pd->Unlock(); //Ready? Go Go Go! lm->Log(L_INFO, "<hio> Starting race..."); if (mainloop) mainloop->SetTimer(checkCheckpoint, 100, 120, NULL, p->arena); chat->SendArenaMessage(p->arena, "Go Go Go!"); //104 //Set time() /* for(i=0; i<maxDrivers; i++) { if (dvr[i].active == 0) continue; dvr[i].lstime = time(); }*/ //lm->Log(L_INFO, "<hio> Race in progress"); } |