SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help > Help Archive

 
 
Thread Tools Display Modes
Old 04/12/2010, 04:46 PM   #1
BlackWolf120
Gangsta
 
BlackWolf120's Avatar
 
Join Date: Nov 2010
Location: Germany
Posts: 761
Reputation: 50
Question HappyHour problem!!

hi,
ive created a happy hour thing:

pawn Code:
forward HappyH(playerid);

public OnPlayerConnect(playerid)
{

SetTimerEx("HappyH",240000,1,"d",playerid);

return 1;
}


new const ValidWeapons[22][2] =
{
    {22, 200}, //9mm
    {23, 150},//9mmsilenced
    {24, 100},//DEagle
    {25, 150},//Shotgun
    {26, 150},//ShawnOFF
    {18, 4},//Molotov
    {16, 4},//Grenade
    {27, 150},//CombatShotgun
    {28, 200},//MicroSmg
    {9, 0},//Chainsaw
    {29, 200}, //MP5
    {30, 250},//AK47
    {31, 250},//M4
    {32, 200},//Tec9
    {33, 100},//CountryRifle
    {34, 100},//SniperRifle
    {35, 15},//RocketLauncher
    {37, 600},//Flamethrower
    {38, 500},//Minigun
    {10, 0},//PDildo
    {8, 0},//Katana
    {4, 0}//Knife
};


public HappyH(playerid)
{

        new r = random(sizeof ValidWeapons);
        GivePlayerWeapon(playerid, ValidWeapons[r][0], ValidWeapons[r][1]);
        SendClientMessage(playerid,0xFF66FFAA, "Happy Hour!! You've got a random weapon gift!");
        new name[ 24 ], string[ 64 ];
        GetPlayerName( playerid, name, 24 );
        format( string, sizeof(string), "~p~%s has got a random weapon gift!!", name );
        GameTextForAll( string, 5000, 5 );
        GivePlayerMoney(playerid,2000);

        return 1;
}

i want that it gives a random weapon to only one player in the server every 4 mins. Now it gives a random weapon to every player in the server every 4 mins.
How to change that??

regards.
BlackWolf120 is offline  
Old 05/12/2010, 03:03 AM   #2
BlackWolf120
Gangsta
 
BlackWolf120's Avatar
 
Join Date: Nov 2010
Location: Germany
Posts: 761
Reputation: 50
Default Re: HappyHour problem!!

pls help me im such a noob
BlackWolf120 is offline  
Old 05/12/2010, 03:37 AM   #3
XePloiT
Huge Clucker
 
XePloiT's Avatar
 
Join Date: Nov 2010
Posts: 299
Reputation: 0
Default Re: HappyHour problem!!

Somewhere at the top:
pawn Code:
new RandomPlayer[MAX_PLAYERS],p=0;
OnPlayerConnect:
pawn Code:
RandomPlayer[p]=playerid;
p++;
Where you want to use it:
pawn Code:
new rand = random(sizeof(RandomPlayer));
HappyH(RandomPlayer[rand]);

hm try this... im not sure if this is the best solution but i think it will work...
__________________
You can find me as "AlExEy" in other forums and places.
"Sex is always the answer, it's never a question,'Cause the answer is yes"
Code:
[ r? ] - 0% [ rAdmin + rBank ] - 99% [ rVehHouse - rHouse + rVehicle ] - 99% [ rWeapon + rExp ] - 5% [ rClan ] - 50% The Whole [ rSystem ] - 63% 100% Dynamic & 100% MySql Database Why 99%? - Cuz Nothin' is Perfect. Releases: rVote - Voting/Poll Script

XePloiT is offline  
Old 15/12/2010, 05:03 PM   #4
BlackWolf120
Gangsta
 
BlackWolf120's Avatar
 
Join Date: Nov 2010
Location: Germany
Posts: 761
Reputation: 50
Question Re: HappyHour problem!!

mhh thx for the code but this doesnt work at all
maybe someone else could give me a hint?
BlackWolf120 is offline  
Old 15/12/2010, 05:11 PM   #5
Marcel
Huge Clucker
 
Join Date: Nov 2007
Posts: 382
Reputation: 2
Default Re: HappyHour problem!!

pawn Code:
forward HappyH();

public OnGameModeInit ()
{

SetTimer("HappyH",240000,true);

return 1;
}


new const ValidWeapons[22][2] =
{
    {22, 200}, //9mm
    {23, 150},//9mmsilenced
    {24, 100},//DEagle
    {25, 150},//Shotgun
    {26, 150},//ShawnOFF
    {18, 4},//Molotov
    {16, 4},//Grenade
    {27, 150},//CombatShotgun
    {28, 200},//MicroSmg
    {9, 0},//Chainsaw
    {29, 200}, //MP5
    {30, 250},//AK47
    {31, 250},//M4
    {32, 200},//Tec9
    {33, 100},//CountryRifle
    {34, 100},//SniperRifle
    {35, 15},//RocketLauncher
    {37, 600},//Flamethrower
    {38, 500},//Minigun
    {10, 0},//PDildo
    {8, 0},//Katana
    {4, 0}//Knife
};


public HappyH()
{
        new players;
        for(new i = 0; i < MAX_PLAYERS; i++)
        {
                if(IsPlayerConnected(i))
                {
                        players++;
                }
        }
    new player = random(players);
        new r = random(sizeof(ValidWeapons));
        GivePlayerWeapon(player, ValidWeapons[r][0], ValidWeapons[r][1]);
        SendClientMessage(player,0xFF66FFAA, "Happy Hour!! You've got a random weapon gift!");
        new name[ 24 ], string[ 64 ];
        GetPlayerName( player, name, 24 );
        format( string, sizeof(string), "~p~%s has got a random weapon gift!!", name );
        GameTextForAll( string, 5000, 5 );
    GivePlayerMoney(player,2000);
    return 1;
}
Marcel is offline  
Old 15/12/2010, 05:17 PM   #6
BlackWolf120
Gangsta
 
BlackWolf120's Avatar
 
Join Date: Nov 2010
Location: Germany
Posts: 761
Reputation: 50
Default Re: HappyHour problem!!

hi,
thx for ur answer im gonna try this out
BlackWolf120 is offline  
 

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
Info Pickup problem [SOLVED] New problem now..... Juanxz Help Archive 2 22/01/2010 07:19 AM
SetVehicleHealth problem (Angle problem SOLVED) Paranoja Help Archive 5 03/08/2009 01:06 PM
problem with CWRP in linux (mysql problem) BSMan Server Support 1 16/06/2009 02:36 PM


All times are GMT. The time now is 08:41 AM.


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