SA-MP Forums Archive
adding 1 to variable to stop re-spawn = fail - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: adding 1 to variable to stop re-spawn = fail (/showthread.php?tid=300826)



adding 1 to variable to stop re-spawn = fail - English-Conceptz - 02.12.2011

ok so i create:

PHP код:
new vcarcheck 0
then

PHP код:
 new color1;
 new 
color2;
 new 
car;
 if(
IsPlayerConnected(playerid))
 {
if(
gPlayerData[playerid][VIP] >= || IsPlayerAdmin(playerid))
            {
                if ( 
sscanfparams"iii"carcolor1color2 ) ) return SendClientMessageplayeridCOLOR_RED"USAGE: {FFFF00}/vspawn [carID] [color1] [color2]" );
                if(
car 400 || car 611)
                {
                    
SendClientMessage(playeridCOLOR_RED"   Vehicle Number can't be below 400 or above 611 !"); return 1;
                }
                if(
color1 || color1 160)
                {
                    
SendClientMessage(playeridCOLOR_RED"   Color Number can't be below 0 or above 160 !"); return 1;
                }
                if(
color2 || color2 126)
                {
                    
SendClientMessage(playeridCOLOR_RED"   Color Number can't be below 0 or above 160 !"); return 1;
                }
                if (
vcarcheck >= 1)
                {
                    
SendClientMessage(playeridCOLOR_RED" Only One vspawn Car May Be Spawned At Any One Time "); return 1;
                }
                new 
Float:X,Float:Y,Float:Z;
                
GetPlayerPos(playeridX,Y,Z);
                
CreateVehicle(carX,Y+2,Z0.0color1color260000);
                
SendClientMessage(playeridCOLOR_RED" Vehicle created.");
                (
vcarcheck += 1);
            } 
in theory in my head when a new car is created, 1 is added to the variable 'vcarcheck'
so then if another one is created the variable will be already 1 and it wont be created.
doesnt work though -.-

and im going to make another command to destroy the car, and to destroy it on log out, time out etc.


help ?


Re: adding 1 to variable to stop re-spawn = fail - Azzeto - 02.12.2011

Try changing (vcarcheck +=1); to vcarcheck = 1;


Re: adding 1 to variable to stop re-spawn = fail - English-Conceptz - 02.12.2011

Quote:
Originally Posted by Azzeto
Посмотреть сообщение
Try changing (vcarcheck +=1); to vcarcheck = 1;
nope, didnt work =[


Re: adding 1 to variable to stop re-spawn = fail - Azzeto - 02.12.2011

Where do you want the other car to stop spawning?


Re: adding 1 to variable to stop re-spawn = fail - English-Conceptz - 02.12.2011

Quote:
Originally Posted by Azzeto
Посмотреть сообщение
Where do you want the other car to stop spawning?
that doesnt really matter but seens you asked, it stops spawning at the players position when the command is called more than once before the first car has been removed or destroyed:

new Float:X,Float:Y,Float:Z;
GetPlayerPos(playerid, X,Y,Z);
CreateVehicle(car, X,Y+2,Z, 0.0, color1, color2, 60000);


Re: adding 1 to variable to stop re-spawn = fail - Azzeto - 02.12.2011

PHP код:
 new color1;
 new 
color2;
 new 
car;
 if(
IsPlayerConnected(playerid))
 {
 if(
gPlayerData[playerid][VIP] >= || IsPlayerAdmin(playerid))
            {
                if ( 
sscanfparams"iii"carcolor1color2 ) ) return SendClientMessageplayeridCOLOR_RED"USAGE: {FFFF00}/vspawn [carID] [color1] [color2]" );
                if(
car 400 || car 611)
                {
                    
SendClientMessage(playeridCOLOR_RED"   Vehicle Number can't be below 400 or above 611 !"); return 1;
                }
                if(
color1 || color1 160)
                {
                    
SendClientMessage(playeridCOLOR_RED"   Color Number can't be below 0 or above 160 !"); return 1;
                }
                if(
color2 || color2 126)
                {
                    
SendClientMessage(playeridCOLOR_RED"   Color Number can't be below 0 or above 160 !"); return 1;
                }
                if (
vcarcheck == 1)
                {
                    
SendClientMessage(playeridCOLOR_RED" Only One vspawn Car May Be Spawned At Any One Time "); return 1;
                }
                new 
Float:X,Float:Y,Float:Z;
                
GetPlayerPos(playeridX,Y,Z);
                
CreateVehicle(carX,Y+2,Z0.0color1color260000);
                
SendClientMessage(playeridCOLOR_RED" Vehicle created.");
                
vcarcheck 1;
            }
            else if (
vcarcheck == 1)
             {
                  
SendClientMessage(playeridCOLOR_RED" Only One vspawn Car May Be Spawned At Any One Time "); return 1;
             } 
Try that.


Re: adding 1 to variable to stop re-spawn = fail - System64 - 02.12.2011

how I understand you:
vcarcheck++