SA-MP Forums Archive
Can some one make a /car [Name/ID] command? - 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: Can some one make a /car [Name/ID] command? (/showthread.php?tid=617981)



Can some one make a /car [Name/ID] command? - Gotham - 29.09.2016

title says it all.


Re: Can some one make a /car [Name/ID] command? - Dayrion - 29.09.2016

It's not the request section. No code, no help. c:


Re: Can some one make a /car [Name/ID] command? - Gotham - 29.09.2016

Cmon I don't have the code I don;t know how to make it without ID :c


Re: Can some one make a /car [Name/ID] command? - Dayrion - 29.09.2016

So let's learn how to make it.
Hmm.. You can take params of the command, check if it's a integer (strval) and make the code if is it or not.


Re: Can some one make a /car [Name/ID] command? - Gotham - 29.09.2016

I use sscanf and zcmd


Re: Can some one make a /car [Name/ID] command? - Dayrion - 29.09.2016

Yes probably but there you don't need sscanf because you will switch between integer or string.
You will need Isnull to check if the params is null (https://sampwiki.blast.hk/wiki/Isnull). You will need to check if it's an integer or not (https://sampwiki.blast.hk/wiki/Strval).


Re: Can some one make a /car [Name/ID] command? - Quinncell - 29.09.2016

Did you even tried looking for a tutorial?
Next time, use "******"!

>https://sampforum.blast.hk/showthread.php?tid=473946


Re: Can some one make a /car [Name/ID] command? - Stinged - 29.09.2016

Quote:
Originally Posted by Dayrion
Посмотреть сообщение
Yes probably but there you don't need sscanf because you will switch between integer or string.
You will need Isnull to check if the params is null (https://sampwiki.blast.hk/wiki/Isnull). You will need to check if it's an integer or not (https://sampwiki.blast.hk/wiki/Strval).
Actually sscanf is the best option, but without creating a wasteful array (params is already there)
strval returns 0 if the string is "0" or the string is null. How will he know which is which?

It can be done with sscanf like this:
Код:
new modelid;
if (!sscanf(params, "i", modelid))
{
	// The player entered an ID, check if it's a valid one (between 400 and 611)
	return 1;
}
// The player entered a string (Even if it's null)
if (isnull(params))
	return SendClientMessage(playerid, -1, "Usage: ...");

// Checking if params is a valid vehicle name here, and then setting "modelid" to the model id.



Re: Can some one make a /car [Name/ID] command? - Dayrion - 29.09.2016

Quote:
Originally Posted by Stinged
Посмотреть сообщение
Actually sscanf is the best option, but without creating a wasteful array (params is already there)
strval returns 0 if the string is "0" or the string is null. How will he know which is which?

It can be done with sscanf like this:
Код:
new modelid;
if (!sscanf(params, "i", modelid))
{
	// The player entered an ID, check if it's a valid one (between 400 and 611)
	return 1;
}
// The player entered a string (Even if it's null)
if (isnull(params))
	return SendClientMessage(playerid, -1, "Usage: ...");

// Checking if params is a valid vehicle name here, and then setting "modelid" to the model id.
If I've corretly undertsood; he wants make a cmd like /v [name OR vehicleid]
So yes, he can use sscanf; My bad.


Re: Can some one make a /car [Name/ID] command? - Gotham - 30.09.2016

Quote:
Originally Posted by KeithCooper
Посмотреть сообщение
Did you even tried looking for a tutorial?
Next time, use "******"!

>https://sampforum.blast.hk/showthread.php?tid=473946
I was looking for an Name/ID system not only ID , I USED "******"