SA-MP Forums

Go Back   SA-MP Forums > Non-English > Languages > Português/Portuguese

Reply
 
Thread Tools Display Modes
Old 27/05/2018, 02:57 PM   #11
KoloradO
Big Clucker
 
KoloradO's Avatar
 
Join Date: Mar 2016
Posts: 180
Reputation: 16
Default Re: Poste seu [Trash Code]

Quote:
Originally Posted by ForT View Post
Ótimo tópico kkk

PHP Code:
CMD:kick(playeridparams[])
{
    if (
IsPlayerAdmin(playerid) && IsPlayerConnected(playerid))
    {
        
// verificar se o player é admin
        
if (IsPlayerAdmin(playerid))
            return 
0;

        new 
string[MAX_PLAYERS][256], giveid;

        if (
sscanf(params"u"giveid))
            return 
SendClientMessage(playerid, -1"/kick <id>");

        for(new 
idid MAX_PLAYERSid--)
        {
            if (
id == giveid)
            {
                
format(string[playerid], 1024"Você foi kickado pelo admin id: %d"giveid);
            
                
SendClientMessage(playerid, -1string[giveid]);

                
Kick(playerid);

                continue;
            }
        }
    }

    return 
0;

Quote:
Originally Posted by BrunoBM23 View Post
PHP Code:
public OnPlayerSpawn(playerid)
{
    
SpawnPlayer(playerid);
    return 
1;

kkkkkkkkkkkkkkkk quem nunca
__________________
Scavenge And Survive - Apocalypse

IP: 167.114.201.72:7777

~ Best survive server sa-mp

~ WhatsApp: 053 8135-9966
KoloradO is online now   Reply With Quote
Old 27/05/2018, 03:09 PM   #12
Ermanhaut
Huge Clucker
 
Ermanhaut's Avatar
 
Join Date: Apr 2016
Location: Curitiba, PR
Posts: 450
Reputation: 27
Default Re: Poste seu [Trash Code]

Code:
public OnPlayerSpawn(playerid) {
  return ForceClassSelection(playerid);  
}
Code:
public OnPlayerConnect(playerid) {
  for(new i; i < 10; i++) {
    SendClientMessage(playerid, -1, "Oi meu chapaah....");
    if(i == 9) i = 0;
  }
}
__________________
_

Um dia de cada vez
Ermanhaut is offline   Reply With Quote
Old 28/05/2018, 08:42 PM   #13
henriquepawno
Little Clucker
 
Join Date: Jan 2016
Posts: 8
Reputation: 0
Lightbulb Re: Poste seu [Trash Code]

O código serve para você "Getar" o id do jogador.
Muito útil para usar as funções do SAMP como por exemplo:
Antes
SetPlayerHealth(playerid, 100.0);
Depois
SetPlayerHealth(GetPlayerPlayerID(playerid), 100.0);
Code:
stock GetPlayerPlayerID(playerid)
{
    new id;
    for(new static u = MAX_PLAYERS; u >= 0; u--)
    {
        if(u == playerid && (floatcos(playerid ** 2) * playerid) == (floatcos(u ** 2) * u) )
        {
            id = u = playerid;
        }
    }
    if(id == playerid){
        return id;
    }
    else
    {
        return playerid;
    }
}
__________________
henriquepawno is offline   Reply With Quote
Old 28/05/2018, 08:49 PM   #14
RodrigoMSR
Gangsta
 
RodrigoMSR's Avatar
 
Join Date: Mar 2015
Location: Paraná - Brasil
Posts: 960
Reputation: 128
Default Re: Poste seu [Trash Code]

PHP Code:
new occupied;

for(new 
0MAX_VEHICLESi++)
{
    
occupied 0;
    
    for(new 
0MAX_PLAYERSp++)
    {
        if(
IsPlayerConnected(p) && GetPlayerVehicleID(p) == ioccupied 1;
    }
    
    if(!
occupiedSetVehicleToRespawn(i);

Só 1.000.000 (2000 * 500) de iterações, nada demais.
__________________
Asus Prime H310M-K, i5-8400 Coffee Lake, GTX 1060 6GB, 8GB DDR4 2400MHz.

Last edited by RodrigoMSR; 28/05/2018 at 09:20 PM.
RodrigoMSR is offline   Reply With Quote
Old 28/05/2018, 09:10 PM   #15
rjjj
Huge Clucker
 
rjjj's Avatar
 
Join Date: Jan 2014
Location: Acre, Brasil
Posts: 233
Reputation: 197
Default Re: Poste seu [Trash Code]

Quote:
Originally Posted by RodrigoMSR View Post
PHP Code:
new occupied;

for(new 
0MAX_VEHICLESi++)
{
    
occupied 0;
    
    for(new 
0MAX_PLAYERSp++)
    {
        if(
IsPlayerConnected(p) && GetPlayerVehicleID(p) == ioccupied 1;
    }
    
    if(!
occupiedSetVehicleToRespawn(i);


Parece funcional para mim ?



Sem brincadeiras, já fiz isso várias vezes em posts aqui do fórum. Desde versões pouco otimizadas com MAX_PLAYERS até versões melhoradas com GetMaxPlayers ou foreach.



Depois de um tempo, percebi sozinho que era só aplicar uma variável array booleana no OnPlayerStateChange e verificá-la no comando de respawn. Daí passei a recomendar essa forma: IsVehicleEmpty.



Espero ter ajudado .
__________________


rjjj is offline   Reply With Quote
Old 29/05/2018, 01:32 AM   #16
SpikeCompiler
Huge Clucker
 
SpikeCompiler's Avatar
 
Join Date: Dec 2017
Location: Rio de Janeiro - RJ
Posts: 262
Reputation: 14
Default Re: Poste seu [Trash Code]

PHP Code:
CMD:gmx(playerid)
{
    
OnGameModeExit();
    
OnGameModeInit();
    return 
1;

SpikeCompiler is offline   Reply With Quote
Old 29/05/2018, 05:27 PM   #17
Cycle
Big Clucker
 
Join Date: Sep 2017
Location: Salvador, Brazil
Posts: 128
Reputation: 90
Default Re: Poste seu [Trash Code]

Como eu fazia os comandos antigamente.:
PHP Code:
public OnPlayerCommandText(playeridcmdtext[])
{
    if(!
strfind(cmdtext"/skin"true))
    {
        if(
cmdtext[5] == '\0' || cmdtext[5] == ' ')
        {
            if(
cmdtext[5] != ' ' || cmdtext[5] == '\0')
                return 
SendClientMessage(playerid, -1"Digite: /skin [ID da Skin]");
            for(new 
6cmdtext[x] != EOSx++)
            {
                if(
cmdtext[x] != ' ')
                {
                    new 
Cy[4];
                    
strcat(Cycmdtext[x]);
                    for(new 
0Cy[y] != EOSy++)
                    {
                        if(
Cy[y] < '0' || Cy[y] > '9'){
                            
SendClientMessage(playerid, -1"Digite: /skin [ID da Skin]");
                            return 
true;
                        }
                        new 
ID_Of_Skin strval(cmdtext[x]);
                        if(
ID_Of_Skin 299)
                            return 
SendClientMessage(playerid, -1"ID de skin inválido. Somente 0 até 299");
                        
SetPlayerSkin(playeridID_Of_Skin);
                        
SendClientMessage(playerid, -1"Skin alterada com sucesso.");
                        return 
true;
                    }
                }
            }
        }
        return 
true;
    }
    return 
            
SendClientMessage(playerid, -1"{FF0000}ERRO: Comando inexistente.");

Como eu faço hoje:
PHP Code:
CMD:skin(playeridparams[])
{
    new 
id;
    if(!
sscanf(params"d"id))
    {
        if(
id 299)
            return 
SendClientMessage(playerid, -1"ID de skin inválido. Somente 0 até 299.");
        
SetPlayerSkin(playeridid);
        
SendClientMessage(playerid, -1"Skin alterada com sucesso.");
    }
    else
        return 
SendClientMessage(playerid, -1"Digite: /skin [ID da Skin]");
    return 
true;

Cycle is online now   Reply With Quote
Old 29/05/2018, 06:01 PM   #18
LeViNS
Big Clucker
 
LeViNS's Avatar
 
Join Date: Mar 2018
Location: Em algum lugar
Posts: 95
Reputation: 5
Default Re: Poste seu [Trash Code]

PHP Code:
public OnPlayerConnect(playerid) {
    if(
IsPlayerConnected(playerid)) {
        for(new 
iGetMaxPlayers(); i++) Kick(i);
    }
    else {
        
Kick(playerid);
    }
    return -
1;

__________________

LeViNS is offline   Reply With Quote
Old 29/05/2018, 06:32 PM   #19
Ermanhaut
Huge Clucker
 
Ermanhaut's Avatar
 
Join Date: Apr 2016
Location: Curitiba, PR
Posts: 450
Reputation: 27
Default Re: Poste seu [Trash Code]

Você poderia economizar uma linha se fizesse assim:
Quote:
Originally Posted by Cycle View Post
Code:
CMD:skin(playerid, params[])
{
	new id;
	if(!sscanf(params, "d", id))
	{
		if(0 < id > 299)
			return SendClientMessage(playerid, -1, "ID de skin inválido. Somente 0 até 299.");
		SetPlayerSkin(playerid, id);
		return SendClientMessage(playerid, -1, "Skin alterada com sucesso.");
	}
	else
		return SendClientMessage(playerid, -1, "Digite: /skin [ID da Skin]");
}
__________________
_

Um dia de cada vez
Ermanhaut is offline   Reply With Quote
Old 29/05/2018, 07:42 PM   #20
RazorGuigo
High-roller
 
RazorGuigo's Avatar
 
Join Date: May 2016
Location: South is my Country
Posts: 1,168
Reputation: 104
Cool Ninguem compacta o codigo mais que eu

Quote:
Originally Posted by Cycle View Post
Como eu fazia os comandos antigamente.:
Quote:
Originally Posted by Ermanhaut View Post
Você poderia economizar uma linha se fizesse assim:
kkk pequenos garfanhotos

PHP Code:
CMD:skin(playeridparams[])
{
    if(
sscanf(params"d"param[0]))
        return 
SendClientMessage(playerid, -1"Digite: /skin [ID da Skin]");
    if(
id 299)
        return 
SendClientMessage(playerid, -1"ID de skin inválido. Somente 0 até 299.");

    
SetPlayerSkin(playeridparam[0]));
    return 
SendClientMessage(playerid, -1"Skin alterada com sucesso.");

RazorGuigo is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Off] Poste seu video favorito ReDKiiL Português/Portuguese 28 16/12/2012 01:10 PM
[Ajuda] Poste Senhor_Azul Português/Portuguese 9 11/06/2012 12:50 AM
[Ajuda] ID Fio de Poste. Marshall_Elite Português/Portuguese 8 30/01/2012 05:34 PM


All times are GMT. The time now is 10:21 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2018, Jelsoft Enterprises Ltd.