[AJUDA] /DarGrana [ID] [Quantia]
#1

Pessoal, eu fiz um comando de /DarGrana, Exemplo, Quando digita '/DarGrana 11' os 11$ vai para vocк, eu queria que digitar-se '/DarGrana [ID] [Quantia]' e der-se o dinheiro e nгo setar-se.

pawn Код:
if(strcmp(cmd, "/dargrana", true) == 0)
    {
        if(IsPlayerAdmin(playerid))
        {
            new money;
            new playa;
            playa = strval(tmp);
            tmp = strtok(cmdtext, idx);
            money = strval(tmp);
            ResetPlayerMoney(playa);
            GivePlayerMoney(playa, money);
        }
        return 1;
    }
Reply
#2

PHP код:
if(strcmp(cmd"/dargrana"true) == 0)
    {
        if(
IsPlayerAdmin(playerid))
        {
            new 
money;
            new 
playa;
            
playa ReturnUser(tmp);
            
tmp strtok(cmdtextidx);
            
money strval(tmp);
            
GivePlayerMoney(playamoney);
        }
        return 
1;
    } 
pronto isso ai so testar
Reply
#3

Quote:
Originally Posted by lucas_mdr1235
Посмотреть сообщение
PHP код:
if(strcmp(cmd"/dargrana"true) == 0)
    {
        if(
IsPlayerAdmin(playerid))
        {
            new 
money;
            new 
playa;
            
playa ReturnUser(tmp);
            
tmp strtok(cmdtextidx);
            
money strval(tmp);
            
GivePlayerMoney(playamoney);
        }
        return 
1;
    } 
pronto isso ai so testar
1 Erro
pawn Код:
[pawnC:\SERVER NR\Servidor [NR]\Servidor [NR]\filterscripts\pwn\admin.pwn(1165) : error 017: undefined symbol "ReturnUser"
Pawn compiler 3.2.3664          Copyright (c) 1997-2006, ITB CompuPhase


1 Error.
Reply
#4

no final do seu GM fora de PUBLIC

PHP код:
ReturnUser(text[], playerid INVALID_PLAYER_ID)
{
    new 
pos 0;
    while (
text[pos] < 0x21// Strip out leading spaces
    
{
        if (
text[pos] == 0) return INVALID_PLAYER_ID// No passed text
        
pos++;
    }
    new 
userid INVALID_PLAYER_ID;
    if (
IsNumeric(text[pos])) // Check whole passed string
    
{
        
// If they have a numeric name you have a problem (although names are checked on id failure)
        
userid strval(text[pos]);
        if (
userid >=&& userid MAX_PLAYERS)
        {
            if(!
IsPlayerConnected(userid))
            {
                
/*if (playerid != INVALID_PLAYER_ID)
                {
                    SendClientMessage(playerid, 0xFF0000AA, "User not connected");
                }*/
                
userid INVALID_PLAYER_ID;
            }
            else
            {
                return 
userid// A player was found
            
}
        }
        
/*else
        {
            if (playerid != INVALID_PLAYER_ID)
            {
                SendClientMessage(playerid, 0xFF0000AA, "Invalid user ID");
            }
            userid = INVALID_PLAYER_ID;
        }
        return userid;*/
        // Removed for fallthrough code
    
}
    
// They entered [part of] a name or the id search failed (check names just incase)
    
new len strlen(text[pos]);
    new 
count 0;
    new 
name[MAX_PLAYER_NAME];
    for (new 
0MAX_PLAYERSi++)
    {
        if (
IsPlayerConnected(i))
        {
            
GetPlayerName(inamesizeof (name));
            if (
strcmp(nametext[pos], truelen) == 0// Check segment of name
            
{
                if (
len == strlen(name)) // Exact match
                
{
                    return 
i// Return the exact player on an exact match
                    // Otherwise if there are two players:
                    // Me and MeYou any time you entered Me it would find both
                    // And never be able to return just Me's id
                
}
                else 
// Partial match
                
{
                    
count++;
                    
userid i;
                }
            }
        }
    }
    if (
count != 1)
    {
        if (
playerid != INVALID_PLAYER_ID)
        {
            if (
count)
            {
                
SendClientMessage(playerid0xFF0000AA"Multiple users found, please narrow earch");
            }
            else
            {
                
SendClientMessage(playerid0xFF0000AA"No matching user found");
            }
        }
        
userid INVALID_PLAYER_ID;
    }
    return 
userid// INVALID_USER_ID for bad return

ajudei +rep
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)