[ARG] Funzioni e Comandi Utili
#303
Inviato il 14 ottobre 2010 - 16:07
GetVehicleSpeed(vehicleid, type) { new Float: Vel[3]; GetVehicleVelocity(vehicleid, Vel[0], Vel[1], Vel[2]); if(type == 1 || type > 2 || type < 1) type = floatround(floatsqroot(Vel[0]*Vel[0] + Vel[1]*Vel[1] + Vel[2]*Vel[2])*200, floatround_floor); else if(type == 2) type = floatround(floatsqroot(Vel[0]*Vel[0] + Vel[1]*Vel[1] + Vel[2]*Vel[2])*200 / 1.609344, floatround_floor); return type; }
Serve per gettare la velocità del veicolo, esempio
GetVehicleSpeed(vehicleid, 1); // prende la velocità sotto forma di Km/h
se mettete al posto di "1" il "2" darà la velocità sotto forma di Mph
se invece mettere un numero maggiore di 2 o minore di 1 darà la velocità sotto forma di Km/h
Messaggio modificato da Angelo_95 il 14 ottobre 2010 - 18:40
#307
Inviato il 14 ottobre 2010 - 18:46
GetVehicleSpeed(vehicleid, type) { new Float: Vel[3]; GetVehicleVelocity(vehicleid, Vel[0], Vel[1], Vel[2]); if(type != 2) type = floatround(floatsqroot(Vel[0]*Vel[0] + Vel[1]*Vel[1] + Vel[2]*Vel[2])*200, floatround_floor); else type = floatround(floatsqroot(Vel[0]*Vel[0] + Vel[1]*Vel[1] + Vel[2]*Vel[2])*200 / 1.609344, floatround_floor); return type; }
Credo sia meglio :S Anche se ti sarebbe venuto meglio fare al posto di type "bool:kmh" e con true voleva dire che si calcolava in Km/h e false Mp/h xD
#308
Inviato il 26 ottobre 2010 - 13:51
if(IsPlayerAdmin(playerid) == 1) {
ShowNameTags(0);
SendClientMessage(playerid, COLOR_RED, "Ora sei invisibile sulla mappa!" );
format(string,sizeof(string),"%s è uscito dal server",name);
SendClientMessageToAll(COLOR_YELLOW,string);
return 1;
}
if(strcmp(cmdtext,"/visibile",true) == 0)
if(IsPlayerAdmin(playerid) == 1) {
ShowNameTags(1);
SendClientMessage(playerid, COLOR_RED, "Ora sei visibile sulla mappa!" );
format(string,sizeof(string),"%s è entrato in server",name);
SendClientMessageToAll(COLOR_YELLOW,string);
return 1;
}
Mi da questi errori:
C:\Documents and Settings\PC\Documenti\GTA San Andreas User Files\Samp Server 0.3b\gamemodes\x3.pwn(1139) : error 017: undefined symbol "name"
C:\Documents and Settings\PC\Documenti\GTA San Andreas User Files\Samp Server 0.3b\gamemodes\x3.pwn(1147) : error 017: undefined symbol "name"
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
2 Errors.
Sapete risolverli ?
#315
Inviato il 04 novembre 2010 - 17:43
/* *Comando Autovelox di BigIlBoss *Vietato lo spaccio di questa opera per propria */ new name[MAX_PLAYER_NAME]; new string[256]; new pid; new tmp[256]; new velocity[256]; public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmd,"/Autovelox",true) == 0) { tmp = strtok(cmdtext,idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE,"[Utilizzo]: /Autovelox [playerid]"); return 1; } pid = strval(tmp); if(!IsPlayerConnected(pid)) { SendClientMessage(playerid, COLOR_ORANGE,"[ATTENZIONE]: Questo giocatore non e' connesso"); return 1; } GetVehicleVelocity(pid, velocity, sizeof(velocity)); GetPlayerName(pid, name, sizeof(name)); format(string,sizeof(string),"La velocità di %s è di %s.", name, velocity); SendClientMessageToAll(COLOR_GREEN, string); return 1; } } return 0; }
#316
Inviato il 04 novembre 2010 - 18:01
BigIlBoss, il 04 novembre 2010 - 17:43 ha detto:
/* *Comando Autovelox di BigIlBoss *Vietato lo spaccio di questa opera per propria */ new name[MAX_PLAYER_NAME]; new string[256]; new pid; new tmp[256]; new velocity[256]; public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmd,"/Autovelox",true) == 0) { tmp = strtok(cmdtext,idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE,"[Utilizzo]: /Autovelox [playerid]"); return 1; } pid = strval(tmp); if(!IsPlayerConnected(pid)) { SendClientMessage(playerid, COLOR_ORANGE,"[ATTENZIONE]: Questo giocatore non e' connesso"); return 1; } GetVehicleVelocity(pid, velocity, sizeof(velocity)); GetPlayerName(pid, name, sizeof(name)); format(string,sizeof(string),"La velocità di %s è di %s.", name, velocity); SendClientMessageToAll(COLOR_GREEN, string); return 1; } } return 0; }
GetVehicleVelocity(pid, velocity, sizeof(velocity)); o.O
la sintassi non era
GetVehicleVelocity(Player, Float:x, Float:y, Float:z); Omg
#317
Inviato il 04 novembre 2010 - 18:13
BigIlBoss, il 04 novembre 2010 - 17:43 ha detto:
/* *Comando Autovelox di BigIlBoss *Vietato lo spaccio di questa opera per propria */ new name[MAX_PLAYER_NAME]; new string[256]; new pid; new tmp[256]; new velocity[256]; public OnPlayerCommandText(playerid, cmdtext[]) { if(strcmp(cmd,"/Autovelox",true) == 0) { tmp = strtok(cmdtext,idx); if(!strlen(tmp)) { SendClientMessage(playerid, COLOR_WHITE,"[Utilizzo]: /Autovelox [playerid]"); return 1; } pid = strval(tmp); if(!IsPlayerConnected(pid)) { SendClientMessage(playerid, COLOR_ORANGE,"[ATTENZIONE]: Questo giocatore non e' connesso"); return 1; } GetVehicleVelocity(pid, velocity, sizeof(velocity)); GetPlayerName(pid, name, sizeof(name)); format(string,sizeof(string),"La velocità di %s è di %s.", name, velocity); SendClientMessageToAll(COLOR_GREEN, string); return 1; } } return 0; }
lol maccheronata
#318
Inviato il 02 gennaio 2011 - 15:12
stock Recolor(playerid) { new string[128]; new name[MAX_PLAYER_NAME]; GetPlayerName(playerid, name, sizeof(name)); format(string, sizeof(string), "Il player %s non è in nessun veicolo!", name); if(!IsPlayerInVehicle(playerid, GetPlayerVehicleID(playerid))) return SendClientMessage(playerid, 0xffffffff, string); new rand = random(127); new rand2 = random(127); ChangeVehicleColor(GetPlayerVehicleID(playerid), rand, rand2); SendClientMessage(playerid, 0xff0000ff, "L' auto è stata ricolorata!"); return 1; }
Serve per ricolorare casualmente il veicolo del playerid inserito tramite la funzione Recolor(playerid).
Poi vabeh, il comando via strtok:
if(strcmp(cmd, "/recolor", true) == 0) { new tmp[128]; tmp = strtok(cmdtext, idx); if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, 0xFFFFFFFF, "Solo gli admin possono usare questo comando."); if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "SCRIVI: /recolor [playerid]"); Recolor(strval(tmp)); return 1; }
EDIT: Funziona ^^
Messaggio modificato da KevinGenoves3 il 02 gennaio 2011 - 15:25
#319
Inviato il 02 gennaio 2011 - 17:43
OnPlayerConnect:
new plrIP[16]; GetPlayerIp(playerid, plrIP, sizeof(plrIP)); new name[24] GetPlayerName(playerid, name, sizeof(name)); format(string9, sizeof(string9), "(%d) %s si è connesso con l'IP", playerid,nameplrIP); SendClientMessageToAll(COLOR_SEAGREEN, string9);
E verrà:
(ID DEL GIOCATORE) GIOCATORE1 si è connesso con l'IP 192.168.1.1 (IP D'ESEMPIO)
Per chi non avesse il colore Sea Green:
#define COLOR_SEAGREEN 0x2E8B57AA
Da incollare insieme agli altri colori.
P.S A chi ha postato gli altri script:
Non fate new string[256],256 sono inutili e aumentano l'utilizzo di CPU al server.Usatene 128 e 24 per i nomi.
===========================
Controlla se il giocatore è in un aereo/elicottero:
stock IsPlayerInPlane(playerid) { if(IsPlayerInAnyVehicle(playerid)) { switch(GetVehicleModel(GetPlayerVehicleID(playerid))) { case 593,592,577,563,553,548,520,519,513,512,511, 497,488,487,476,469,460,447,425,417,493,484,453: return 1; default: return 0; } } return 0; }
Messaggio modificato da SubZero il 02 gennaio 2011 - 17:43
Scripto qualsiasi tipo di gamemode/piccole funzioni ad un ottimo prezzo.
Contattatemi,100% fidato.
NO PERDITEMPO O Bimbiminkia O "Non ti pago ma ti faccio diventare admin".
Pagamenti accettati: PayPal.
Mandatemi un messaggio privato se siete interessati.