GTA-Expert Forum: [ARG] Funzioni e Comandi Utili - GTA-Expert Forum

Salta al contenuto

  • (18 Pagine)
  • +
  • « Primo
  • 14
  • 15
  • 16
  • 17
  • 18
  • Non puoi iniziare una nuova discussione
  • Non puoi rispondere a questa discussione

[ARG] Funzioni e Comandi Utili

#301 L'utente è offline   Mozilla 

  • Assassino
  • Gruppo: Utenti
  • Messaggi: 2525
  • Iscritto il: 10/09/10
  • Provenienza:Palermo
  • GTA Preferito:GTA: San Andreas

Inviato il 10 ottobre 2010 - 21:25

in questo caso dovresti fare un timer o altro, se nò esegue la funzione 1 volta sola, altrimenti metterlo nell'onplayerconnect, così funziona sempre
Immagine Postata
0

#302 L'utente è offline   Angelo_95 

  • Cacciatore di taglie
  • Gruppo: Utenti
  • Messaggi: 1620
  • Iscritto il: 31/08/09
  • Provenienza:Area 51
  • GTA Preferito:GTA: San Andreas

Inviato il 10 ottobre 2010 - 22:00

basta un comando cosi li banna tutti :D
Immagine Postata
0

#303 L'utente è offline   Angelo_95 

  • Cacciatore di taglie
  • Gruppo: Utenti
  • Messaggi: 1620
  • Iscritto il: 31/08/09
  • Provenienza:Area 51
  • GTA Preferito:GTA: San Andreas

Inviato il 14 ottobre 2010 - 16:07

Posto una funzione che si puo dire quasi inutile, visto che ne esistono molte versioni, però voglio postarla ugualmente:

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

Immagine Postata
0

#304 L'utente è offline   Peppinux aka Peppe_Stasu 

  • Sicario
  • Gruppo: Utenti
  • Messaggi: 2056
  • Iscritto il: 16/04/10
  • GTA Preferito:GTA: San Andreas

Inviato il 14 ottobre 2010 - 16:27

Ti sarebbe bastato fare if(type == 1 || type > 2) al posto di fare if(type == 1) e else if(type > 2 || type < 1) return type = 1; :/
0

#305 L'utente è offline   Rapgangsta 

  • Tirapiedi
  • Gruppo: Banned
  • Messaggi: 1044
  • Iscritto il: 21/10/09
  • GTA Preferito:Sconosciuto

Inviato il 14 ottobre 2010 - 17:16

Visualizza MessaggiPeppinux aka Peppe_Stasu, il 14 ottobre 2010 - 17:27 ha detto:

Ti sarebbe bastato fare if(type == 1 || type > 2) al posto di fare if(type == 1) e else if(type > 2 || type < 1) return type = 1; :/


oppure piu semplicemente if(type != 1)
0

#306 L'utente è offline   Angelo_95 

  • Cacciatore di taglie
  • Gruppo: Utenti
  • Messaggi: 1620
  • Iscritto il: 31/08/09
  • Provenienza:Area 51
  • GTA Preferito:GTA: San Andreas

Inviato il 14 ottobre 2010 - 18:40

ho fatto semplicemente

if(type == 1 || type > 2 || type < 1)

cioè se type è uguale a 1 o è maggiore di 2 o è minore di 1 darà sempre la velocità in Km/h
Immagine Postata
0

#307 L'utente è offline   Peppinux aka Peppe_Stasu 

  • Sicario
  • Gruppo: Utenti
  • Messaggi: 2056
  • Iscritto il: 16/04/10
  • GTA Preferito:GTA: San Andreas

Inviato il 14 ottobre 2010 - 18:46

Fai così:
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
0

#308 L'utente è offline   Ale_Gta 

  • Delinquente
  • Gruppo: Utenti
  • Messaggi: 438
  • Iscritto il: 28/09/10
  • Provenienza:C:\Programmi\Rockstar Games\GTA San Andreas\Sicilia
  • GTA Preferito:GTA: San Andreas

Inviato il 26 ottobre 2010 - 13:51

if(strcmp(cmdtext,"/invisibile",true) == 0)
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 ?


Livello Scripter: Apprendista
0

#309 L'utente è offline   Angelo_95 

  • Cacciatore di taglie
  • Gruppo: Utenti
  • Messaggi: 1620
  • Iscritto il: 31/08/09
  • Provenienza:Area 51
  • GTA Preferito:GTA: San Andreas

Inviato il 26 ottobre 2010 - 15:04

scusa perchè hai postato qua :facepalm: crea una nuova discussione no ?
Immagine Postata
0

#310 L'utente è offline   Ale_Gta 

  • Delinquente
  • Gruppo: Utenti
  • Messaggi: 438
  • Iscritto il: 28/09/10
  • Provenienza:C:\Programmi\Rockstar Games\GTA San Andreas\Sicilia
  • GTA Preferito:GTA: San Andreas

Inviato il 26 ottobre 2010 - 15:15

Xche un utente ho postato questo comando qui mi sembrava il posto piu adatto
Livello Scripter: Apprendista
0

#311 L'utente è offline   Peppinux aka Peppe_Stasu 

  • Sicario
  • Gruppo: Utenti
  • Messaggi: 2056
  • Iscritto il: 16/04/10
  • GTA Preferito:GTA: San Andreas

Inviato il 26 ottobre 2010 - 15:25

Devi aprire un nuovo topic.
0

#312 L'utente è offline   Ale_Gta 

  • Delinquente
  • Gruppo: Utenti
  • Messaggi: 438
  • Iscritto il: 28/09/10
  • Provenienza:C:\Programmi\Rockstar Games\GTA San Andreas\Sicilia
  • GTA Preferito:GTA: San Andreas

Inviato il 26 ottobre 2010 - 15:30

Va bene lo faro dopo aver risolto il caso dei dm
Livello Scripter: Apprendista
0

#313 L'utente è offline   Rapgangsta 

  • Tirapiedi
  • Gruppo: Banned
  • Messaggi: 1044
  • Iscritto il: 21/10/09
  • GTA Preferito:Sconosciuto

Inviato il 26 ottobre 2010 - 16:21

facevate prima a dirli che bastava mettere
new name[24];
-.-
0

#314 L'utente è offline   Ale_Gta 

  • Delinquente
  • Gruppo: Utenti
  • Messaggi: 438
  • Iscritto il: 28/09/10
  • Provenienza:C:\Programmi\Rockstar Games\GTA San Andreas\Sicilia
  • GTA Preferito:GTA: San Andreas

Inviato il 26 ottobre 2010 - 16:34

Grazie xD


Livello Scripter: Apprendista
0

#315 L'utente è offline   BigIlBoss 

  • Cleptomane
  • Gruppo: Utenti
  • Messaggi: 140
  • Iscritto il: 01/08/10
  • Provenienza:Las Venturas, la capitale dei crimini
  • GTA Preferito:GTA: San Andreas

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;
}

0

#316 L'utente è offline   Angelo_95 

  • Cacciatore di taglie
  • Gruppo: Utenti
  • Messaggi: 1620
  • Iscritto il: 31/08/09
  • Provenienza:Area 51
  • GTA Preferito:GTA: San Andreas

Inviato il 04 novembre 2010 - 18:01

Visualizza MessaggiBigIlBoss, 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
Immagine Postata
0

#317 L'utente è offline   Rapgangsta 

  • Tirapiedi
  • Gruppo: Banned
  • Messaggi: 1044
  • Iscritto il: 21/10/09
  • GTA Preferito:Sconosciuto

Inviato il 04 novembre 2010 - 18:13

Visualizza MessaggiBigIlBoss, 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
0

#318 L'utente è offline   KevinGenoves3 

  • Tirapiedi
  • Gruppo: Utenti
  • Messaggi: 609
  • Iscritto il: 05/07/10
  • Provenienza:Zena

Inviato il 02 gennaio 2011 - 15:12

Non testato, ma il compilatore non da errori, più tardi lo provo:
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

Immagine Postata


Immagine PostataRegisterMe v 2.0 Immagine PostataImmagine PostataImmagine PostataImmagine PostataImmagine PostataImmagine Postata




0

#319 L'utente è offline   SubZero 

  • Cittadino Onesto
  • Gruppo: Utenti
  • Messaggi: 13
  • Iscritto il: 02/01/11
  • GTA Preferito:GTA: San Andreas

Inviato il 02 gennaio 2011 - 17:43

Funzione facile facile per leggere l'ip di un giocatore quando si connette:


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

Scripter privato.
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.
0

#320 L'utente è offline   .ReVo^ 

  • Criminale
  • Gruppo: Utenti
  • Messaggi: 1402
  • Iscritto il: 20/11/08
  • GTA Preferito:GTA: TBoGT

Inviato il 02 gennaio 2011 - 19:02

SubZero quel tuo codice è sbagliato non uscirà mai (ID DEL GIOCATORE) GIOCATORE1 si è connesso con l'IP 192.168.1.1 (IP D'ESEMPIO)
ma (ID) ip si è connesso con l'IP
Poi definisci la variabile new name[24] senza mettere la ; alla fine.
Immagine Postata
0

  • (18 Pagine)
  • +
  • « Primo
  • 14
  • 15
  • 16
  • 17
  • 18
  • Non puoi iniziare una nuova discussione
  • Non puoi rispondere a questa discussione

1 utenti stanno leggendo questa discussione
0 utenti, 1 ospiti, 0 utenti anonimi