SA-MP Forums

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

 
 
Thread Tools Display Modes
Old 14/03/2010, 05:12 AM   #1
sexybeast
Little Clucker
 
Join Date: Apr 2009
Posts: 27
Reputation: 0
Default Adding a time limit on /equip

I just wanted to add a 1 minute wait between the time someone can use /equip in a HQ, here is my cmd

Code:
if(strcmp(cmd, "/equip", true) == 0)
{
new playhq = PlayerInfo[playerid][pGang]-1;
if (PlayerToPoint(50, playerid,HQInfo[playhq][hqExitx], HQInfo[playhq][hqExity], HQInfo[playhq][hqExitz]))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s gets equipped", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
if ((HQInfo[playhq][hqGun1])||(HQInfo[playhq][hqGun2])||(HQInfo[playhq][hqGun3])||(HQInfo[playhq][hqGun4]) > 1)
{
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun1],HQInfo[playhq][hqAmo1]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun2],HQInfo[playhq][hqAmo2]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun3],HQInfo[playhq][hqAmo3]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun4],HQInfo[playhq][hqAmo4]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun5],HQInfo[playhq][hqAmo5]);
}
if (HQInfo[playhq][hqHel] == 1)
{
SetPlayerHealth(playerid,100.0);
SendClientMessage(playerid, TEAM_GREEN_COLOR,"You have been healed to 100 health");
}
if (HQInfo[playhq][hqArm] == 1)
{
SetPlayerArmour(playerid,100.0);
SendClientMessage(playerid, TEAM_GREEN_COLOR,"You put on body armour");
}
format(string, sizeof(string), "You picked up some weapon's");
SendClientMessage(playerid, TEAM_GREEN_COLOR,string);
printf("%s", string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "You are not in a gang HQ");
return 1;
}
}

If someone could kindly tell me how i can do this, that would be greatly appreciated
sexybeast is offline  
Old 14/03/2010, 05:38 AM   #2
Deat_Itself
Gangsta
 
Join Date: May 2009
Location: UAE (Abudhabi,Shahama)
Posts: 600
Reputation: 4
Default Re: Adding a time limit on /equip

use


http://wiki.sa-mp.com/wiki/SetTimer
Deat_Itself is offline  
Old 14/03/2010, 09:54 AM   #3
sexybeast
Little Clucker
 
Join Date: Apr 2009
Posts: 27
Reputation: 0
Default Re: Adding a time limit on /equip

I tried adding this into my script but it doesn't seem to fit in appropriately. I am still learning how to script and try and learn as much as i can by trail and error but i cant seem to get this one right. So i was wondering if you or anyone could work out what i need to do in order for this to run with my script. Thanks again.
sexybeast is offline  
Old 14/03/2010, 09:59 AM   #4
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 418
Reputation: 3
Default Re: Adding a time limit on /equip

Really easy one

set a variable

Code:
new wait;
within /equip do this at the top:

Code:
wait = 1;
then set a timer

Code:
SetTimer("mytimer", 60000, 0);
thats a 60 second timer

function

Code:
forward mytimer();
public mytimer(){
return wait=0;
}
then all you need is an if within your function

Code:
if(wait == 1){
cant do this
}
else{
your script
}
adsy is offline  
Old 14/03/2010, 10:40 AM   #5
sexybeast
Little Clucker
 
Join Date: Apr 2009
Posts: 27
Reputation: 0
Default Re: Adding a time limit on /equip

Thanks for that, but i had a bit of trouble adding it into my cmd as seen below. I added the "new wait;" part but as of everything else was unsure where it all fits in, if you wouldn't mind putting it into this for me that would be awesome and much appreciated.

Code:
if(strcmp(cmd, "/equip", true) == 0)
{
new playhq = PlayerInfo[playerid][pGang]-1;
if (PlayerToPoint(50, playerid,HQInfo[playhq][hqExitx], HQInfo[playhq][hqExity], HQInfo[playhq][hqExitz]))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s gets equipped", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
if ((HQInfo[playhq][hqGun1])||(HQInfo[playhq][hqGun2])||(HQInfo[playhq][hqGun3])||(HQInfo[playhq][hqGun4]) > 1)
{
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun1],HQInfo[playhq][hqAmo1]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun2],HQInfo[playhq][hqAmo2]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun3],HQInfo[playhq][hqAmo3]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun4],HQInfo[playhq][hqAmo4]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun5],HQInfo[playhq][hqAmo5]);
}
if (HQInfo[playhq][hqHel] == 1)
{
SetPlayerHealth(playerid,100.0);
SendClientMessage(playerid, TEAM_GREEN_COLOR,"You have been healed to 100 health");
}
if (HQInfo[playhq][hqArm] == 1)
{
SetPlayerArmour(playerid,100.0);
SendClientMessage(playerid, TEAM_GREEN_COLOR,"You put on body armour");
}
format(string, sizeof(string), "You picked up some weapon's");
SendClientMessage(playerid, TEAM_GREEN_COLOR,string);
printf("%s", string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "You are not in a gang HQ");
return 1;
}
}
sexybeast is offline  
Old 14/03/2010, 11:12 AM   #6
sexybeast
Little Clucker
 
Join Date: Apr 2009
Posts: 27
Reputation: 0
Default Re: Adding a time limit on /equip

If someone could just quickly edit the pawn code for me, and add in the specific things i would greatly appreciate it.
sexybeast is offline  
Old 14/03/2010, 05:38 PM   #7
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 418
Reputation: 3
Default Re: Adding a time limit on /equip

Code:
if(strcmp(cmd, "/equip", true) == 0)
{

SetTimer("mytimer", 60000, 0);
if(wait[playerid] == 1){
//CANT DO THIS CODE HERE
}
else{
wait[playerid] = 1;
new playhq = PlayerInfo[playerid][pGang]-1;
if (PlayerToPoint(50, playerid,HQInfo[playhq][hqExitx], HQInfo[playhq][hqExity], HQInfo[playhq][hqExitz]))
{
GetPlayerName(playerid, sendername, sizeof(sendername));
format(string, sizeof(string), "* %s gets equipped", sendername);
ProxDetector(30.0, playerid, string, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
if ((HQInfo[playhq][hqGun1])||(HQInfo[playhq][hqGun2])||(HQInfo[playhq][hqGun3])||(HQInfo[playhq][hqGun4]) > 1)
{
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun1],HQInfo[playhq][hqAmo1]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun2],HQInfo[playhq][hqAmo2]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun3],HQInfo[playhq][hqAmo3]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun4],HQInfo[playhq][hqAmo4]);
GivePlayerWeapon(playerid,HQInfo[playhq][hqGun5],HQInfo[playhq][hqAmo5]);
}
if (HQInfo[playhq][hqHel] == 1)
{
SetPlayerHealth(playerid,100.0);
SendClientMessage(playerid, TEAM_GREEN_COLOR,"You have been healed to 100 health");
}
if (HQInfo[playhq][hqArm] == 1)
{
SetPlayerArmour(playerid,100.0);
SendClientMessage(playerid, TEAM_GREEN_COLOR,"You put on body armour");
}
format(string, sizeof(string), "You picked up some weapon's");
SendClientMessage(playerid, TEAM_GREEN_COLOR,string);
printf("%s", string);
return 1;
}
else
{
SendClientMessage(playerid, COLOR_GRAD2, "You are not in a gang HQ");
}
return 1;
}
}

create the function as shown in previous post outside all other functions

same with this line

Code:
new wait[MAX_PLAYERS];
Code:
forward mytimer(playerid);
public mytimer(playerid){
return wait[playerid]=0;
}
adsy is offline  
Old 15/03/2010, 09:22 AM   #8
sexybeast
Little Clucker
 
Join Date: Apr 2009
Posts: 27
Reputation: 0
Default Re: Adding a time limit on /equip

Ok seems to work fine now, i tried adding in a cmd like "SendClientMessage(playerid, COLOR_RED, "You can only /equip once a minute" but doesn't do anything. Thanks for your help.
sexybeast is offline  
Old 15/03/2010, 01:01 PM   #9
adsy
Huge Clucker
 
Join Date: Aug 2008
Posts: 418
Reputation: 3
Default Re: Adding a time limit on /equip

you want that line here:

Code:
if(wait[playerid] == 1){
//CANT DO THIS CODE HERE (HERE)
}
adsy 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
Time Limit On Command gtapolicemods Help Archive 2 25/03/2010 02:00 AM
how to make report time limit cmd? buonggiorno Help Archive 6 11/01/2010 08:44 AM
Equip? Namaco Help Archive 9 07/12/2009 05:13 PM
Setting time limit. help please? Drift_04 Help Archive 3 25/02/2009 10:29 PM
setting a time limit and making a score. Drift_04 Help Archive 1 25/02/2009 04:26 AM


All times are GMT. The time now is 08:27 PM.


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